我想根据git文档,从git历史记录中删除一些文件/文件夹,但由于存在未提交的更改
,它失败了。我不清楚可能有哪些未提交的更改,因为我之前使用了 git add --all
、提交和push。请注意,要删除的文件夹somefolder/
在HEAD中不存在了。它是在早期的提交中移动的,但它的旧版本需要从仓库中清除。
~$ git add --all
~$ git commit -m "trying to fix 'Cannot rewrite branches: You have unstaged changes'"
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
~$ git push
Everything up-to-date
~$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
~$ git filter-branch --force --index-filter "git rm --cached --ignore-unmatch somefolder/" --prune-empty --tag-name-filter cat -- --all
Cannot rewrite branches: You have unstaged changes.
~$
我该如何修复这个问题,以便我能够成功运行最后一个命令?
git status
的输出是什么? - Cameron Little