无法推送,因为我在本地提交了一个太大的文件
Can't push because I locally committed a file that is too large
(以防万一,这是在 Github Enterprise 上)
我无法将更改推送到存储库,因为我无意中将两个过大的文件提交到我的本地存储库。这两个文件超过了 github 允许的大小。我现在在本地有几个 origin 的提交。我不关心大文件并已删除它们,但 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'
- 我想将我当前的本地仓库推送到 github 仓库。
- 我根本不关心过大的文件。我不需要将它们推到github。
- 我的本地仓库在 github 仓库之前有很多提交。文件过大的提交不是最新的。
有没有一种方法可以解决此问题,而无需将我的本地存储库一直滚动回添加大文件的提交?
没有。您必须重建历史记录,删除所有包含大文件的提交。
这样做:
git rebase -i origin/master master
如果你的错误提交只是大文件的添加,只需删除它们,删除 rebase todo 文件中的相关行。
如果您的大文件属于更复杂的提交,请在每个相关行的 rebase todo 文件中使用 "edit" 选项。当 rebase 操作在提交修改后停止时:
git rm bigFile1 bigFile2
git commit --amend
git rebase --continue
终止变基,必要时解决所有冲突。
终于再推一次
我发现你可以
git reset --soft <commit>
其中 "commit" 是您提交大文件的提交。 (您可以使用 git 日志列出您的分支提交)然后
git rm --cached "largeFileName"
然后提交并推送。
据我了解,软重置会在不更改本地文件的情况下将您更改回之前的提交。 git rm --cached 撤消你之前的 git 添加 "largeFileName" 所以它不会为提交
git status 是一个有用的命令,用于查看 git 准备提交的内容(当我的大文件最终离开舞台时,它以绿色列为已删除)
(以防万一,这是在 Github Enterprise 上)
我无法将更改推送到存储库,因为我无意中将两个过大的文件提交到我的本地存储库。这两个文件超过了 github 允许的大小。我现在在本地有几个 origin 的提交。我不关心大文件并已删除它们,但 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'
- 我想将我当前的本地仓库推送到 github 仓库。
- 我根本不关心过大的文件。我不需要将它们推到github。
- 我的本地仓库在 github 仓库之前有很多提交。文件过大的提交不是最新的。
有没有一种方法可以解决此问题,而无需将我的本地存储库一直滚动回添加大文件的提交?
没有。您必须重建历史记录,删除所有包含大文件的提交。
这样做:
git rebase -i origin/master master
如果你的错误提交只是大文件的添加,只需删除它们,删除 rebase todo 文件中的相关行。
如果您的大文件属于更复杂的提交,请在每个相关行的 rebase todo 文件中使用 "edit" 选项。当 rebase 操作在提交修改后停止时:
git rm bigFile1 bigFile2
git commit --amend
git rebase --continue
终止变基,必要时解决所有冲突。
终于再推一次
我发现你可以
git reset --soft <commit>
其中 "commit" 是您提交大文件的提交。 (您可以使用 git 日志列出您的分支提交)然后
git rm --cached "largeFileName"
然后提交并推送。
据我了解,软重置会在不更改本地文件的情况下将您更改回之前的提交。 git rm --cached 撤消你之前的 git 添加 "largeFileName" 所以它不会为提交
git status 是一个有用的命令,用于查看 git 准备提交的内容(当我的大文件最终离开舞台时,它以绿色列为已删除)