github에 100MB 이상 push 하기.

영석·2025년 4월 21일

Git

목록 보기
1/1
post-thumbnail

🚨 발생 원인

gitlab에서 했던 프로젝트를 github로 옮기려고 했다.
프로젝트 코드 + commit 메시지 내역 등을 한 번에 옮기려고 했는데 문제가 생겼습니다.

remote: Resolving deltas: 100% (4812/4812), done.
remote: error: Trace: c8115ed37ee052ccbf0cf957bece41a44fba9432fe67faaec0d40e60acd29827
remote: error: See https://gh.io/lfs for more information.
remote: error: File python/kcelectra_sentiment/model.safetensors is 416.14 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/kobenlys/Jippy.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: 레퍼런스를 'https://github.com/kobenlys/Jippy.git'에 푸시하는데 실패했습니다

파이썬 모델파일 용량이 416MB라서 github에 푸시하는데 실패했습니다.
이유는 github에서 push시 100mb 제한을 두고 있었기 때문입니다.

이를 해결하는 과정을 남겨보겠습니다.

🛠️ 해결과정

1. HomeBrew로 lfs, filter-repo 설치

brew install git-filter-repo
brew install git-lfs
  • filter-repo*는 로컬 저장소의 히스토리를 완전히 재작성 합니다.
  • lfs는 대용량데이터를 git에 push할때 사용합니다.

2. 100mb가 넘는 파일 git 히스토리에서 제거

git filter-repo --path python/kcelectra_sentiment/model.safetensors --invert-paths
  • commit 내역까지 push하기 때문에 히스토리에서 100mb가 넘어가는 파일을 제거 해줘야 합니다.

3. 가장 마지막 커밋에 반영된 것만 추가하려면 (선택임)


# lfs 초기화
git lfs install

# LFS 설정 트래킹 할 파일 지정
git lfs track "python/sentiment/model.safetensors"

# .gitattributes 추가 후 커밋
git add .gitattributes
git add python/kcelectra_sentiment/model.safetensors
git commit -m "chore: using lfs"

# push 하기
git push origin main

commit 히스토리에는 100mb되는 파일을 제거하고 가장 마지막 커밋의 파일만 LFS로 관리하면 된다. 😋

profile
느리게 갱신되는 개발실력 - >_0

0개의 댓글