The git filter-branch fails with "Cannot rewrite branch(es) with a dirty working directory message" if "git rm" command was run before it. In spite of "Cannot rewrite branch(es) with a dirty working directory message, git filter-branch command managed to erase the specified folder. Therefore, I don't understand what the error message really means and any impact on what I am doing.
I am on Linux with git version 1.7.1. Please see below for exact commands.
git clone ...
cd /home/userid/fpcnav_test
git rm -q -r -f --ignore-unmatch olddir1
git filter-branch --force --index-filter "git rm -q -r -f --ignore-unmatch olddir2 --prune-empty --tag-name-filter cat -- --all
It seems that "git rm" makes working directory dirty which fails the git filter-branch command. I workaround this by running git stash (or got commit -m ...) command between git rm and git filter commands. My intention is to run series of "git rm" and "git filter-branch" commands but can't do it cleanly unless I do git stash between each git rm and git filter-branch. Is there a clean way to do this or not? Eventually, I will be running these commands against the original repository and not under cloned repository. Thanks.