#.100MB를 넘어가는 크기의 파일을 지닌 저장소 미러링하기
1.git lfs와 BFG Repo Cleaner를 설치합니다.
2. 복사하고자 하는 저장소(github)의 clone을 생성합니다.
git clone --mirror {gitlab 레포지토리 주소}
3.커밋 히스토리 내에서 large file을 찾아 트랙킹 합니다.
git filter-branch --tree-filter 'git lfs track "*.{zip,jar}"' -- --all
4.BFG를 이용하여 해당 파일들을 git lfs로 변경합니다.
java -jar {BFG Repo Cleaner위치 클론한 폴더라면 ../000.jar} --convert-to-git-lfs '*.zip'
java -jar {BFG Repo Cleaner위치 ../000.jar} --convert-to-git-lfs '*.jar'
5.새로운 저장소(github)로 mirror-push를 진행
git push --mirror {github 레포지토리 주소}
**gitlab과 github의 주소가 다르다면 github/ setting / email에 gitlab 이메일 추가
lfs를 이용하여 리파짓토리 미러링하기Permalink
github의 경우 100MB 이상의 커밋은 위의 방법으로 옮길 수 없다
LFS를 사용해서 용량이 큰 커밋이력을 옮기는 방법은 다음과 같다
- git bash를 연다
- A를 clone받기
$ git clone --bare https://[A주소]
- 폴더 이동
$ cd [A주소.git]
- Pull in the repository’s git large file storage objects
$ git lfs fetch --all
- 새 리파짓토리로 mirror-push
$ git push --mirror https://[B주소]
- 큰 파일 푸시푸시
$ git lfs push --all https://[B 주소]
- 이전에 A 폴더 지우기
$ cd .. $ rm -rf [A폴더]
reject 당하면
BFG Repo-Cleaner 사용하기Permalink
위의 방법에서 remote rejected같은 오류가 난다면..
검색하니까 커밋이력 중에서도 100MB가 넘는 파일이 있기 때문이라고한다(github에 올릴때)
커밋이력에도 100MB가 넘는 파일이 있는 경우 + 100MB넘는 파일이 있을 때 방법은 다음과 같다
- A를 clone을 bare로 받는다
$ git clone --mirror [A.git]
- A.git 폴더와 같은 경로에 BFG RepoCleaner 을 다운받는다.
$ ls A.git bfg-1.13.0.jar
- A.git폴더에서 100mb넘는 것을 제거(저장소 정리)
$ java -jar bfg.jar --strip-blobs-bigger-than 100M [A.git]
-
$ cd [A.git] $ git reflog expire --expire=now --all && git gc --prune=now --aggressive $ git push # push하면 변경된 상태를 remote repository에도 업데이트
- github에 올리기
git remote -v 로 해당 리파짓토리에 연결된 원격 저장소를 확인할 수 있다.$ git remote add [remote이름 : github][올릴 github repository 주소 : https://github.com/hongjuzzang/B.git]
-
$ git push github
'Git' 카테고리의 다른 글
[GIT] Coding Convention (0) | 2023.03.06 |
---|---|
[GIT]branch 생성 및 변경 (0) | 2023.03.06 |
[Git] clone,push,checkout (0) | 2023.02.03 |