Git LFS

1 minute read

Git LFS

먼저 Git LFS를 사용하기 전에 왜 사용하는지에 대해서 알아보자.
GigHub에서 다음과 같이 설명하고 있다.

We recommend repositories be kept under 1GB each. Repositories have a hard limit of 100GB. If you reach 75GB you’ll receive a warning from Git in your terminal when you push. This limit is easy to stay within if large files are kept out of the repository. If your repository exceeds 1GB, you might receive a polite email from GitHub Support requesting that you reduce the size of the repository to bring it back down. In addition, we place a strict limit of files exceeding 100 MB in size.

위의 내용을 살펴보게 되면 GitHub 이제한하는 용량은 다음과 같다.

  • GitHub 계정 용량: 100GB
  • Repository 용량: 1GB
  • File 용량: 100MB

이러한 이유로 인하여 GItHub에 100MB이상의 용량의 파일은 Upload하지 못한다.
따라서 100MB이상의 용량의 File은 Git LFS를 통하여 File을 올려야한다.


GitLFS 사용 방법

GitLFS를 설치하기 위하여 다음과 같은 과정을 거치게 된다.
1. GitLFS 설치

curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install


2. File 등록
git lfs track [File 명]
.gitignore에 제외할 File을 등록하는 것과 같은 방식으로서 100MB이상의 File을 다음과 같은 명령어를 통해 등록하여야 한다.
ex) git lfs track '*.bag'
위의 명령어 실행으로 인하여 File등록이 완료되게 되면 .gitattributes File이 생성되고 다음과 같이 작성되어 진다.
.gitattributes File 내용
*.bag filter=lfs diff=lfs merge=lfs -text

3. git Repository 가져오기
git clone or git pull등을 통하여 lfs가 등록된 Repository를 가져오게 되면

  1. Git Repository내용 가져오기(lfs File 제외)
  2. LFS File가져오기

의 과정으로 인하여 2번 인증을 통해서 Git Repository를 가져올 수 있다.

최종적으로 정리하자면 100MB File이상이나 1GB미만의 File을 Git에 올리고 싶을때는 git lfs를 통하여 Fiel을 업로드 할 수 있다.


코드에 문제가 있거나 궁금한 점이 있으면 wjddyd66@naver.com으로 Mail을 남겨주세요.

Categories:

Updated:

Leave a comment