Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git filter-branch says working tree is dirty when it is not

I'm trying to rewrite my history in my git repository because I need to remove a file that contains restricted information.

This is what happens:

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

So I think "that's weird, I'm pretty sure I don't have uncommitted changes", and I run:

$ git status -u
# On branch master
nothing to commit (use -u to show untracked files)

What is going on here? Does anyone have an idea for what could be happening? There are submodules in this repository.

Submodule Staging Info

I have 18 submodules (all Vim plugins), and here are their statuses. Thought this might be useful info.

$ 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)

Other info

$ git diff-files --ignore-submodules --quiet
$ echo $?
1
$ git diff-index --cached --quiet HEAD --
$ echo $?
0
like image 252
dwlz Avatar asked Jun 24 '11 05:06

dwlz


1 Answers

This is mostly a guess, but the error may be caused by a bug that was fixed in git v1.7.7.1 (which was released after your original post). From the commit message:

Filter-branch already requires that we have a clean work tree before starting. However, it failed to refresh the index before checking, which means it could be wrong in the case of stat-dirtiness.

like image 61
Richard Hansen Avatar answered Sep 27 '22 18:09

Richard Hansen