我试图在我的git仓库中重写历史记录,因为我需要删除一个包含限制信息的文件。
具体情况如下:
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch FILE' master
Cannot rewrite branch(es) with a dirty working directory.
所以我认为“这很奇怪,我相当确定我没有未提交的更改”,然后我运行:
$ git status -u
# On branch master
nothing to commit (use -u to show untracked files)
这里发生了什么事情?有人知道可能发生了什么吗?这个代码库中有子模块。
子模块阶段信息
我有18个子模块(全部是Vim插件),下面是它们的状态。我认为这可能是有用的信息。
$ for i in $(ls); do cd $i; git status -u; cd ..; done;
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# On branch master
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
# Not currently on any branch.
nothing to commit (working directory clean)
其他信息
$ git diff-files --ignore-submodules --quiet
$ echo $?
1
$ git diff-index --cached --quiet HEAD --
$ echo $?
0
git status
之后再次尝试使用filter-branch
了吗?也许只是文件的时间戳发生了变化,而filter-branch
没有检查以删除脏标记。 - Tobias Kienzlergit status -u
显示什么?您是否尝试删除任何未跟踪的文件或在全新克隆上执行此操作? - X-Istencegit status -u
显示相同的输出。 - dwlz