(以防它有所不同,这是在Github Enterprise上)
我无法将更改推送到回购,因为我无意中将两个过大的文件提交到我的本地仓库。这两个文件超出了github允许的大小。我现在在当地几个承诺的起源。我不关心大文件,因此删除了它们,但git push origin
每次仍然失败。
当我检查github中的最后一次提交时,repo落后10天,这意味着不仅大文件失败,而且整个推送失败。我显然不能再推动我的回购了。每次我尝试,我都会收到此错误:
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: File lib/abc.csv is 482.56 MB; this exceeds GitHub Enterprise's file size limit of 150.00 MB
remote: error: File lib/xyz.csv is 604.82 MB; this exceeds GitHub Enterprise's file size limit of 150.00 MB
To https://github.foobar.com/userx/myrepo
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.foobar.com/userx/myrepo'
有没有办法解决这个问题,而不必将我的本地仓库一直回到添加大文件的提交中?
答案 0 :(得分:1)
没有。您必须重建历史记录,删除包含大文件的所有提交。
这样做:
git rebase -i origin/master master
如果你的错误提交只是一个大文件的添加,只需删除它们删除rebase todo文件中的相关行。
如果您的大文件属于更复杂的提交,请使用"编辑"每个相关行的rebase todo文件中的选项。当rebase操作在提交修改后停止时:
git rm bigFile1 bigFile2
git commit --amend
git rebase --continue
终止rebase,必要时解决所有冲突。
最后再次推。
答案 1 :(得分:0)
我发现你可以
git reset --soft <commit>
其中&#34;提交&#34;是您提交大文件的提交。 (你可以使用git log列出你的分支提交)然后
git rm --cached "largeFileName"
然后提交并推送。
我理解的是,软重置会将您更改回上一次提交而不更改本地文件。 git rm --cached撤消你之前的git add&#34; largeFileName&#34;所以它没有为提交
而上演git status是一个有用的命令,用于查看git准备提交的内容(当我的大文件最终离开舞台时,它将其列为绿色删除)