My cleaning filter failed to apply (a separate issue unrelated to Git) resulting in Git storing "dirty" files. I fixed the filter, but now I need to clean the files and then store them again.
I know from another question of mine that if files were commited without a filter when there is an active filter present, no matter what I do those files will be seen as changed since the hashes will fail to match up. No ammount of git reset --hard
or git stash
will fix this, nor anything else.
My first thought was to do an interactive rebase. However, even with --force
it won't let me. With the force option, it simply says it can't be done, but without it Git complains about unstaged changes.
cannot rebase: you have unstaged changes
I tried looking for a way to force Git to ignore unstaged changes, but all that lead to were the usual methods of HANDLING unstaged changes (ie reset
and stash
).
I'm currently trying to do the rebase manually, but for some reason it isn't working as expected. Its too soon to give more details than that, and its time for some lunch. I'm going mentioning this now since it came up in the comments.
The only solution I can think of is to set the current working directory aside, then git reset --hard last-good-commit
. I'd then move the files back and commit, however I'd lose history, and I don't want that.
By "losing history" I mean the commits leading up to the "present" will be lost. I wish to avoid this.
How do force a rebase in this scenario?
The answer was to disable filters and then apply the filters manually as I rebase. As I had mentioned in the comments, there was a bit of a snag. That snag was that doing so resulted in empty commits. The solution to that was to remove the commit since it was an automated commit in the first place which is also the reason the filter wasn't applied.
In ~/.bashrc I have a load path defined for the lib I wrote which is used by the filter scripts. The problem was that the automated git commit script was bypassing that environmental variable causing the cleaning script to fail. The solution to this was to specify the path to the lib explicitly in the script.