我正在尝试从 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
但这会导致错误:
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
没有其他程序保持 /revs 打开。 /revs 不存在于指定路径和 .git-rewrite 中is empty.
我不确定应该在哪里添加 -r?
否则命令是否错误?
当然,我确实需要将 bin 本身保留在本地本地存储库中,因为这是我的工作目录。
Thanks
好的,我需要做的就是将 -r 添加到 rm 命令部分(如下所示)。我guess这是因为 bin 是一个目录而不是文件,所以它must被递归删除,否则它包含的文件(或有关它们的信息)将被孤立。
$ 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)