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.
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)
$ git diff-files --ignore-submodules --quiet
$ echo $?
1
$ git diff-index --cached --quiet HEAD --
$ echo $?
0
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With