我正试图将一个仓库从GitLab迁移到GitHub。仓库的大小是685.83MB,其中包括几个 .dat,.csv,.exe,.pkl
超过100MB的文件到3383.40MB,出现以下错误。
GitLab To GitHub Migration Steps:-
$ git clone --mirror [email protected]:test/my-repo.git
$ cd ~/my-repo.git
$ git remote set-url --push origin [email protected]:test/my-repo.git
$ git push
Error
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: File Src/project/label/file1.dat is 476.32 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
remote: error: File Src/models/label/file2.dat is 2431.49 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
remote: error: File test/test1/label/model/file3.exe is 1031.94 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
remote: error: File test/test2/usecase/filemarker/file3.csv is 997.02 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
remote: error: File src/msg/sports/model.pkl is 3383.40 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
remote: error: File test/movie/maker/marker.dat is 1373.45 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
remote: error: File project/make/level/project/realmaker.csv is 1594.83 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
remote: error: File src/moderm/network/test.pkl is 111.07 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
Git LFS/BFG Method:
$ git clone --mirror gitlab-heavy-repo
$ cd gitlab-heavy-repo.git
$ java -jar bfg-1.12.5.jar --convert-to-git-lfs '*.dat' --no-blob-protection
$ java -jar bfg-1.12.5.jar --convert-to-git-lfs '*.exe' --no-blob-protection
$ java -jar bfg-1.12.5.jar --convert-to-git-lfs '*.csv' --no-blob-protection
$ java -jar bfg-1.12.5.jar --convert-to-git-lfs '*.pkl' --no-blob-protection
$ git reflog expire --expire=now --all && git gc --prune=now
$ git lfs install
$ git remote set-url origin [email protected]:some-org/githubheavy-repo.git
$ git push
看来Git LFS有2GB的限制。所以尝试将以上大文件从版本库中完全删除。按照下面的方法删除。
1) git clone gitlab-heavy-repo
2) cd gitlab-heavy-repo
3) git filter-branch --force --index-filter "git rm --cached --ignore-unmatch Src/project/label/file1.dat" --prune-empty --tag-name-filter cat -- --all
4) git reflog expire --expire=now --all
5) git gc --prune=now
6) git push origin --force --all
7) git push origin --force --tags
8) rm -rf .git/refs/original/
对以上所有大文件重复同样的步骤。但现在在 Gitlab 仓库中,存储空间大小显示----------。1.9-GB
最初只是 685.83MB.
请指正。先谢谢你。
你可以运行这个来添加所有超过100MB的文件到.gitignore。
find . -size +100M | cat >> .gitignore
取自 此处.
之后,要从.gitignore中读取文件,并从repo中删除它们(不从磁盘上删除它们),运行以下命令(只适用于Linux)。
git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
Taken from 此处
更新如果您已经提交了这些文件,您需要从提交历史中清除它们。首先,确认您已经将错误信息中的所有文件添加到您的.gitignore中。 然后对每个文件执行以下命令,将其从之前的所有提交中删除。
git filter-branch --prune-empty -d /dev/shm/scratch \
--index-filter "git rm --cached -f --ignore-unmatch path/to/file" \
--tag-name-filter cat -- --all
@GregBacon在他的回答中对这个命令做了更好的解释。此处