본문 바로가기

프로그래밍 언어/Git

Github에서 Git LFS 를 이용하여 대용량 파일 올리기

개요

먼저 Git LFS를 사용하기 전에 왜 사용해야하는지에 대해셔 알아보도록 하겠습니다.

GitHub는 다음과 같이 설명하고 있습니다.

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 계정의 최대 용량은 100GB이다. (git push 할때 75GB를 넘기면 알려주는 듯 합니다... )
  • 리파지토리당 용량은 1GB로 유지하는 것을 권장한다.
  • 하나의 파일 용량은 100MB 로 제한된다.

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

GitLFS 사용 방법

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

1. GitLFS 설치하기

Debian/Ubuntu

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

Mac

  • Homebrew : brew install git-lfs
  • MacPorts : port 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 [리파지토리 URL]

lfs가 등록된 Repository를 가져오게 되면

  1. Git Repository내용 가져오기(lfs File 제외)
  2. LFS File가져오기
    의 과정으로 인하여 2번 인증을 통해서 Git Repository를 가져올 수 있습니다.