본문 바로가기
Programming/git

[git] git lfs 로 대용량 파일 관리하기

by didi0di 2025. 4. 15.
728x90

 

먼저 아래 git-lfs 공식 사이트에서 OS에 맞는 파일을 다운로드 한다.

 

https://git-lfs.com/

 

Git Large File Storage

Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.

git-lfs.com

 

리눅스 git-lfs 설치 관련 자세한 내용은 아래 깃헙 내용 참고.

https://github.com/git-lfs/git-lfs/blob/main/INSTALLING.md

 

git-lfs/INSTALLING.md at main · git-lfs/git-lfs

Git extension for versioning large files. Contribute to git-lfs/git-lfs development by creating an account on GitHub.

github.com

 

 

 

나는 리눅스라서 아래 명령어로 설치를 해줬다.


  
apt-get install git-lfs

 

 

설치가 완료 되었다면 아래 명령어 실행하면 된다.


  
$ git lfs install
Git LFS initialized.

 

 

업로드할 대용량 파일에 트래킹을 설정한 후 .gitattributes 파일을 커밋 목록에 추가까지 해주면 끝! 

  • 와일드카드(*)를 이용해 복수 파일을 지정할 수도 있음
  • .gitattributes 파일에는 파일에 대한 트래킹 내역이 기록됨

 

나는 PDF 파일이 100mb 이상 대용량 파일들이라, 아래와 같이 설정해줬다.

git lfs track "*.pdf"
> Tracking "*.pdf"

git add .gitattributes

 

이제 파일을 add하고 commit 한 후에 push 해주면 된다.

 

이렇게 LFS object를 업로드한다고 나옴.

 

 

참고 : https://guide.ncloud-docs.com/docs/sourcecommit-use-lfs

 

728x90

댓글