使用BFG Repo-Cleaner从GitHub存储库中删除以前提交的文件 [英] Removing files from past commits in GitHub repository with BFG Repo-Cleaner

查看:698
本文介绍了使用BFG Repo-Cleaner从GitHub存储库中删除以前提交的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的GitHub存储库中有一个文件,我想从我以前的提交中删除。我使用了BFG Repo-Cleaner的 delete-files 命令,它似乎可行,但是当我继续使用GitHub存储库时,该文件仍然保留在以前的所有提交中。如果我再次尝试执行命令,它会给我一个


BFG中止:No refs to update - no dirty commitits found ??


我误解BFG的工作原理吗?如果是的话我该如何从GitHub上提交的文件中删除该文件?



以下是我采用的步骤:


  1. 使用 - mirror 标志将我的GitHub repo的副本克隆到本地文件夹中。

  2. 然后将 cd 添加到我的本地visual studio项目中。 然后我输入命令 java -jar bfg-1.12.1.13.jar --delete-files< .json file我想要删除>
  3. < / code>
  4. 然后输入 git reflog expire --expire = now - 全部&& git gc --prune = now --aggressive

  5. $ git push


解决方案

单独使用 git push a href =https://rtyley.github.io/bfg-repo-cleaner/ =nofollow> BFG repo cleaner 会重写回购的历史记录。



它应该可以工作,当你克隆(像你一样) - mirror ,因为在 git push

注意:

,本地更新的引​​用将在远程端强制更新。

>

默认情况下,HEAD分支受到保护,并且在清除其历史记录时,最新的提交('提示')是受保护的提交,并且其文件层次根本不会被改变。

在回推之前,不要忘记从HEAD(当前工作树)中删除文件。

>

After 讨论,似乎命令没有在正确的文件夹中执行。该文件夹应该以 .git xxx.git 结尾:a clone --mirror 是裸露的回购。


I have a file in my GitHub repository that I would like to remove from my previous commits. I used BFG Repo-Cleaner's delete-files command and it appeared to work, but when I go on my GitHub repository the file is still on all the previous commits. If I try and do the command again, it gives me a

BFG aborting: No refs to update - no dirty commits found??

Am I misunderstanding how BFG works? If so how can I remove the file from my past commits on GitHub?

Here are the steps I took:

  1. Cloned a copy of my GitHub repo into a local folder using the --mirror flag.
  2. I then cd to my local visual studio project.
  3. I then entered in the command java -jar bfg-1.12.1.13.jar --delete-files <.json file I wanted to delete> <my local clone copy from step 1>.git
  4. I then entered in git reflog expire --expire=now --all && git gc --prune=now --aggressive
  5. Ran git push

解决方案

A git push alone should not work, since BFG repo cleaner does rewrite the history of a repo.

It should work though when you cloned (as you did) with --mirror, since, on git push, locally updated refs will be force updated on the remote end.

Note that:

By default the HEAD branch is protected, and while its history will be cleaned, the very latest commit (the 'tip') is a protected commit and its file-hierarchy won't be changed at all.

Don't forget to remove your file from your HEAD (current working tree) as well, before pushing back.

After discussion, it seems the commands were not executed in the right folder. That folder should end with .git: xxx.git: a clone --mirror is a bare repo.

这篇关于使用BFG Repo-Cleaner从GitHub存储库中删除以前提交的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆