«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Link
관리 메뉴

영만이네

git lfs 설치와 적용 본문

개발/Forgettable

git lfs 설치와 적용

YoungMaan 2022. 9. 30. 17:19

- git에는 용량 제한이 있음

- git-lfs를 이용하여 큰 용량의 데이터도 업로드 가능

- git-lfs를 권한 없이 설치

git-lfs 설치

1. git-lfs binary 파일 설치 (https://github.com/git-lfs/git-lfs/releases)

$ wget https://github.com/git-lfs/git-lfs/releases/download/v3.2.0/git-lfs-linux-386-v3.2.0.tar.gz

 

2. 압축 풀기

$ tar -zxvf git-lfs-linux-386-v3.2.0.tar.gz

 

3. install.sh의 prefix를 쓰기 권한이 있는 디렉토리로 지정

 

  - $PATH 확인

$ echo $PATH
$ /bin:/usr/bin:.../home/myaccount/bin:...

 

  - $PATH 중에 쓰기 권한이 있는 경로로 prefix 수정

#install.sh
#!/usr/bin/env bash
set -eu

prefix="/home/myaccount" # here


if [ "${PREFIX:-}" != "" ] ; then
  prefix=${PREFIX:-}
elif [ "${BOXEN_HOME:-}" != "" ] ; then
  prefix=${BOXEN_HOME:-}
fi
...

 

 4. install.sh 실행

$ sh install.sh
Git LFS initialized

 

git 적용

1. push하고자 하는 디렉토리에서 git-lfs install

$ git lfs install

2. 원하는 데이터 포멧 지정

  - track을 지정하면 .gitattributes 파일이 생성

  - 디렉토리 전체를 지정하려면 "/**"를 이용하여 지정 (https://stackoverflow.com/questions/35769330/git-lfs-track-folder-recursively)

$ git lfs track "*.jsonl"
$ git lfs track "data_path/**"

 

3. 업로드

$ git add .
$ git commit -m "Add data"
$ git push

 

git login multiple times...

git-lfs 적용 후 push 할 때, 로그인을 여러번 요구하는 현상이 있었음. (https://github.com/git-lfs/git-lfs/issues/203#issuecomment-91307223) 아래의 config 변경으로 해결

git config --global credential.helper cache

 

Comments