How to revert a 'git filter-branch -f --env-filter'
-
01-06-2021 - |
Domanda
I am quite a newb regarding git and usually git commit, pull and push are the only commands I do. Recently noticed that my commits were set to a default name and email and wanted to change it. Stupidly I ran this which I found in a post somewhere:
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='newemail';
GIT_COMMITER_NAME='Newname'; GIT_COMMITTER_EMAIL='newemail';" HEAD
I thought this would change only my commits, but instead it changed all commits in the repo to have my name and email. Of course to continue my "dumbness" I pushed the changes.
Also I seem to have lost history and all commits on github seem to have a duplicate entry as well. One with my name and email and the original one.
Is there a way to revert this? Maybe using a copy of a previous pull to push the original info?
Soluzione 3
A colleague was able to speak with some git pros and it seems that a 'git push -f' from a previous copy solved the issue. Also, I needed to do a git pull --rebase on my copy.
Thanks for your help guys.
Altri suggerimenti
If you haven't done anything to clean up loose objects after you did the filter-branch command, you can reset your master branch (assuming HEAD was master when you gave the command):
git reset --hard refs/original/master
If you didn't cleanup yet you can reset your branch with : git reset --hard refs/original/master
this will reload all the original files prior to your attempt then do:
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='newemail'; GIT_COMMITER_NAME='Newname'; GIT_COMMITTER_EMAIL='newemail';" "--tag-name-filter cat -- --all"