从git-git命令中删除历史记录失败 [英] Removing history from git - git command fails

查看:442
本文介绍了从git-git命令中删除历史记录失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从Git历史中清除项目bin目录。我已经将'bin'添加到.gitignore并成功运行 $ git rm --cached -r bin 。现在我已经尝试使用GitHub帮助页面推荐的命令来清除历史记录:

  $ git filter-branch  - force --index-filter \ 
'git rm --cached --ignore-unmatch bin'\
--prune-empty --tag-name-filter cat - --all

但这会导致错误:

 重写< hash> (1/164)fatal:不删除'bin'不带-r 
索引过滤失败:git rm --cached --ignore-unmatch bin
rm:无法删除'c:/ pathToMyLocalRepo /。 git-rewrite / revs':Permission denied
rm:can not remove directory'c:/pathToMyLocalRepo/.git-rewrite':Directory not empty

没有其他程序保持/打开。 / revs在指定的路径中不存在,.git-rewrite 为空。



我不确定我应该在哪里添加 - R'
这个命令是不正确的吗?

我当然需要将bin本身保留在本地本地回购库中,因为这是我的工作目录。 p>

谢谢

解决方案

好的,所有我需要做的就是添加 - r到rm命令部分(如下所示)。我猜这是因为bin是一个目录而不是文件,因此它必须被递归地删除,否则它所包含的文件(或者它们的相关信息)将被孤立。

  $ git filter-branch --force --index-filter \ 
'git rm --cached -r --ignore-unmatch bin'\
--prune-empty --tag-name-filter cat - --all

我跟着下面的内容将这些更改推送到github上的远程仓库

  $ git push origin master --force 


Im trying to purge a projects bin directory from Git history. I have already added 'bin' to .gitignore and run $git rm --cached -r bin successfully. Now I have tried using the command as recommended in the GitHub help pages to purge the history:

$ git filter-branch --force --index-filter \
  'git rm --cached --ignore-unmatch bin' \
  --prune-empty --tag-name-filter cat -- --all

But this results in errors:

Rewrite <hash> (1/164) fatal: not removing 'bin' recursively without -r
index filter failed: git rm --cached --ignore-unmatch bin
rm: cannot remove 'c:/pathToMyLocalRepo/.git-rewrite/revs': Permission denied
rm: cannot remove directory 'c:/pathToMyLocalRepo/.git-rewrite': Directory not empty

There's no other programs holding /revs open. /revs does not exist in the specified path and .git-rewrite is empty.

I am not sure where exactly I should add the -r? Is the command incorrect otherwise?

I do, of course, need to keep bin itself in the local local repo as this is my working dir.

Thanks

解决方案

Okay so all I needed to do was add the -r to the rm command part (as below). I guess this is because bin is a directory rather than a file, so it must be removed recursively as otherwise the files it contains (or the information about them) would be orphaned.

$ git filter-branch --force --index-filter \
  'git rm --cached -r --ignore-unmatch bin' \
  --prune-empty --tag-name-filter cat -- --all

I followed this with the below to push the changes to the remote repo on github

$ git push origin master --force

这篇关于从git-git命令中删除历史记录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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