我把一个150MB的视频文件添加到了我的项目源文件中,无意中提交了这个文件。我尝试用git push
把这个提交推送到远程仓库,但是我注意到这个推送操作卡住了一段时间,最终失败了,并显示如下信息:
Counting objects: 17, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (17/17), 145.48 MiB | 138.00 KiB/s, done.
Total 17 (delta 13), reused 0 (delta 0)
remote: Resolving deltas: 100% (13/13), completed with 12 local objects.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 8b4191f1a1055e7dea4412f80b5125d2
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File src/images/greystone_place.mp4 is 145.45 MB; this exceeds GitHub's file size limit of 100.00 MB
我尝试将该文件添加到.gitignore
中,但为时已晚。随后的git push
命令产生了相同的结果。
接下来,我尝试重置HEAD --soft
到我最初提交这个大文件的提交记录(在涉及.gitignore
的几个更多提交之后)。然后,我使用git reset HEAD -- path/to/filename
将该文件重置到工作目录并再次提交。然而,这样做仍然遇到相同的错误。
后来我意识到,也许使用--amend
命令会奏效(基于这篇文章),但这也没有起作用。
我还尝试在软重置中使用git rm --cached path/to/file
。这也失败了。
我已经开始阅读关于git rebase i
和git filter-branch
的文章,但它们似乎很复杂,我不确定这种方法是否正确。
我不是Git专家,但简单来说,我想用我的其他更改进行git push
,并排除这个大文件。不知何故,它似乎纠缠在早期的提交中,导致我无法向远程存储库进行push
。