오늘의 인기 글
최근 글
최근 댓글
Today
Total
05-04 00:00
관리 메뉴

우노

[GitHub] Git LFS를 사용한 100MB 이상의 파일 업로드 본문

DevOps/GitHub

[GitHub] Git LFS를 사용한 100MB 이상의 파일 업로드

운호(Noah) 2021. 5. 20. 20:22

에러

  • GitHub은 기본적으로 100MB 이상의 파일을 올릴 수 없습니다.

      Total 2501 (delta 119), reused 0 (delta 0)
      remote: Resolving deltas: 100% (119/119), done.
      remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
      remote: error: Trace: b247f8bc263dc538b0eb5c72346bd0bebf9c4e7f9805d28c1ada7d063bdfcf95
      remote: error: See http://git.io/iEPt8g for more information.
      remote: error: File xgboost/lib/libxgboost.so is 487.75 MB; this exceeds GitHub's file size limit of 100.00 MB
      To https://github.com/unhochoi/packages-layer-of-lambda.git
       ! [remote rejected] main -> main (pre-receive hook declined)
      error: 레퍼런스를 'https://github.com/unhochoi/packages-layer-of-lambda.git'에 푸시하는데 실패했습니다

해결방법

  • git-lfs를 사용해, Commit 과정에 지정한 파일을 작게 조각내어 해결할 수 있습니다.

git-lfs 설치

  • Ubuntu

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

      brew install git-lfs
  • CentOS

      curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash
      sudo yum install git-lfs 

Repository 에 lfs 적용

# 업로드 파일이 존재하는 Repository 로 이동한 후
git lfs install

만약, 이전에 해당 업로드 파일에 대한 git add 기록이 존재한다면 unstaging

git rm -r --cached "*"

Repository 내에서, 업로드하고자 하는 파일을 선택

git lfs track "파일명"

.gitattributes 와 업로드 파일을 ADD, Commit, Push

  • lfs 로 트래킹하는 파일에 대한 정보는 .gitattributes 을 통해서 관리되므로,

  • .gitattributes 와 업로드 파일은 같이 add 돼야합니다.

      git add .gitattributes
      git add "파일명"
      git commit -m "커밋메세지"
      git push origin main
Comments