我将一个 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
Run Code Online (Sandbox Code Playgroud)
我尝试添加该文件,.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远程仓库。
从GitHub 上关于从历史记录中删除文件的教程开始,您可以使用该bfg工具或git filter-branch按照您在问题中提到的方式使用:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' --prune-empty --tag-name-filter cat -- --all
Run Code Online (Sandbox Code Playgroud)
之后,您可能需要强制推送 ( ),因为历史记录已被修改。git push -f
我不确定我的这种方法是否找错了方向。
您可能首先有一个备份:-) GitHub 可能是另一个备份(因为您的推送失败)。
| 归档时间: |
|
| 查看次数: |
5018 次 |
| 最近记录: |