ensuring a cancelled git filter-branch does not change any file in repo

62 Views Asked by At

I recently ran the command git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch utils.js" in a feature branch with the aim of removing a file from my git repo/history (I did this locally and planned to push to github). However, once the command outputted Rewrite <git hash> (123/1122) (102 seconds passed, remaining 802 predicted) I learned that git filter-branch potentially can alter files without my knowledge, and thus I cancelled it with ctrl+c. No files to be committed were recorded in VSCode. I then switched to the master branch and ran git fetch --all and git reset --hard origin/master. My latest commit for master locally is the same as that on github's master, and vscode shows no files to be committed (which I take to mean no files have been changed). However, the documentation at https://git-scm.com/docs/git-filter-branch states that says "git filter-branch has a plethora of pitfalls that can produce non-obvious manglings of the intended history rewrite" - is anyone able to confirm that the steps I have taken with git fetch --all and git reset --hard origin/master are enough to ensure that my files are ok, or are there other things I need to do to make sure that the git filter-branch command didn't change any other file in my repo?

1

There are 1 best solutions below

2
matt On

You should have duplicated your working tree folder before running such a dangerous command, and the docs tell you to do so, but it seems you didn't. The state of your local repo is thus in doubt. Best course of action: Throw your project away and make a new clone.