Git过滤器分支说工作树不是很脏

Dan*_*erz 9 git command-line

我正在尝试在我的git存储库中重写我的历史记录,因为我需要删除包含受限信息的文件.

这是发生的事情:

$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch FILE' master
Cannot rewrite branch(es) with a dirty working directory.
Run Code Online (Sandbox Code Playgroud)

所以我认为"这很奇怪,我很确定我没有未提交的更改",我运行:

$ git status -u
# On branch master
nothing to commit (use -u to show untracked files)
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?有没有人知道会发生什么?此存储库中有子模块.

子模块分段信息

我有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)
Run Code Online (Sandbox Code Playgroud)

其他信息

$ git diff-files --ignore-submodules --quiet
$ echo $?
1
$ git diff-index --cached --quiet HEAD --
$ echo $?
0
Run Code Online (Sandbox Code Playgroud)

Ric*_*sen 7

这主要是猜测,但错误可能是由git v1.7.7.1(在您的原始帖子之后发布)中修复的错误引起的.从提交消息:

Filter-branch已经要求我们在开始之前有一个干净的工作树.但是,它在检查之前无法刷新索引,这意味着在stat-dirtyiness的情况下它可能是错误的.

  • @JP:在我的回答中链接的修复导致`git filter-branch`运行以下内容来刷新索引:`git update-index -q --ignore-submodules --refresh` (4认同)