[英]How do I remove an unpushed commit caused by a large file in the repo that has since been deleted?
I am fairly beginner in git.我是 git 的初学者。 My repo has simple MATLAB code files.
我的仓库有简单的 MATLAB 代码文件。 I made the mistake of uploading a large file into the repo (> 100 MB).
我犯了将大文件上传到仓库(> 100 MB)的错误。 After that, I used the following commands
之后,我使用了以下命令
git add --all
git commit --all --message "Moar"
git push --all
The push command threw up the following error: push 命令抛出以下错误:
remote: error: GH001: Large files detected.
远程:错误:GH001:检测到大文件。 You may want to try Git Large File Storage - https://git-lfs.github.com .
您可能想尝试 Git 大文件存储 - https://git-lfs.github.Z4D2366D9A2FEDA4BEC50 remote: error: Trace: 47cf7a12aa48e59e3007901d70e3843b remote: error: See http://git.io/iEPt8g for more information.
远程:错误:跟踪:47cf7a12aa48e59e3007901d70e3843b 远程:错误:有关更多信息,请参阅http://git.io/iEPt8g 。 remote: error: File prepro/workbench-windows64-v1.3.2/workbench/bin_windows64/rfMRI_REST1_LR_Atlas.dtseries.nii is 418.46 MB;
远程:错误:文件 prepro/workbench-windows64-v1.3.2/workbench/bin_windows64/rfMRI_REST1_LR_Atlas.dtseries.nii 为 418.46 MB; this exceeds GitHub's file size limit of 100.00 MB... !
这超过了 GitHub 的文件大小限制 100.00 MB...! [remote rejected] master -> master (pre-receive hook declined)
[remote denied] master -> master (pre-receive hook denied)
I then panicked and deleted the above large file that was causing the error.然后我惊慌失措并删除了导致错误的上述大文件。 But now I still get the same errors when I try to push to my master!!
但是现在当我尝试推送给我的主人时,我仍然会遇到同样的错误!
These large files do not exist in my local repo anymore.这些大文件不再存在于我的本地仓库中。 So why isn't git letting me push?
那么为什么git不让我推呢? Also, I have some changes in the local repo after this happened so I cannot revert back to the most recent commit without these large files.
此外,发生这种情况后,我在本地存储库中进行了一些更改,因此如果没有这些大文件,我无法恢复到最近的提交。
Is there a way to cleanly and precisely do it by letting git know that the large files do not exist in the repo anymore?有没有办法通过让 git 知道回购中不再存在大文件来干净而准确地做到这一点?
Since you are a beginner, read this answer it will supply a lot of information to you.由于您是初学者,请阅读此答案,它将为您提供很多信息。 How to move HEAD back to a previous location?
如何将 HEAD 移回之前的位置? (Detached head) & Undo commits
(分离的头)和撤消提交
In order to remove content from old commit, im recommending this tool:为了从旧提交中删除内容,我推荐这个工具:
https://rtyley.github.io/bfg-repo-cleaner/ https://rtyley.github.io/bfg-repo-cleaner/
It the perfect tool for this kind of task它是此类任务的完美工具
BFG Repo-Cleaner
BFG 回购清洁剂
an alternative to git-filter-branch.
git-filter-branch 的替代方案。
The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history:
BFG 是 git-filter-branch 的更简单、更快的替代方案,用于从 Git 存储库历史记录中清除不良数据:
- Removing Crazy Big Files
删除疯狂的大文件
- Removing Passwords, Credentials & other Private data
删除密码、凭证和其他私人数据
In all these examples bfg is an alias for java -jar bfg.jar.
在所有这些示例中,bfg 是 java -jar bfg.jar 的别名。
# Delete all files named 'id_rsa' or 'id_dsa' :
bfg --delete-files id_{dsa,rsa} my-repo.git
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.