简体   繁体   English

如何删除由 repo 中的大文件导致的未推送提交,该文件已被删除?

[英]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删除密码、凭证和其他私人数据

Examples (from the official site)示例(来自官方网站)

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.

相关问题 如何从尚未推送到git的原始提交中删除文件更改? - How do I remove a file change from a commit that has not been pushed to origin in git? 如何从已推送到远程仓库的 git 提交中删除特定文件? - How to remove a particular file from a git commit which has been pushed to remote repo? 在更改/删除 repo 后,从 git repo 中删除大文件 - Removing large file from git repo, after the repo has been changed/deleted 如何修复未推送的合并commit(git)? - How do I fix an unpushed merge commit(git)? 由于Git在每次提交时都会记录每个文件的全部内容,因此我该如何处理大型文件和Git? - Since Git records the entire content of each file on every commit, how do I work with large files and Git? 从先前未推送的提交中删除文件 - Remove a file from a previous unpushed commit 如何在 Visual Studio 中删除未推送的传出提交? - How to remove an unpushed outgoing commit in Visual Studio? 我如何获得git来推送一个月前已“删除同步”的存储库,该存储库已删除到github上的新存储库以进行共享? - how do i get git to push a repository i “repo sync” a month ago that has been deleted to a new repository on github to share? 我的本地git repo已“未暂存”已删除的文件,远程是文件,如何提取丢失的文件? - my local git repo has “not staged” deleted files, remote is file, how do I pull the missing files? 如何从已删除的Git存储库中恢复代码(文件) - How to recover code (a file) from a Git repository that has been deleted since
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM