You can try rebasing
but you said you had issues with it, or you can try a sort of an undo
with git reflog
. I leave both options bellow:
Undo with Git Reflog
You mentioned that you would like to undo the results of the filter command, so you can try to run:
> $ git reflog
d363d7c HEAD@{0}: commit: minor typo
87c9470 HEAD@{1}: pull: Fast-forward
a74a14e HEAD@{2}: checkout: moving from clojure-script-begginer to master
ce79d4e HEAD@{3}: commit: article for review
a74a14e HEAD@{4}: checkout: moving from master to clojure-script-begginer
a74a14e HEAD@{5}: pull: Fast-forward
14ec10b HEAD@{6}: checkout: moving from cors to master
e71cf74 HEAD@{7}: commit: Config URL commented out
If you see a list like this and you can notice an entry before the filter command was ran you can just reset your branch to that point:
> git reset --hard <COMMIT ID>
COMMIT ID
would be any number on the first column of git reflog
Rebasing
1. Create another branch
Don't execute any of the steps in the branch you currently have the 100 commits, as we're going to go into dangerous zone quite for quite a bit.
Assuming you're at master:
> git checkout -b fixing-duplicates
2. Interactive rebase to delete duplicates
Run:
> git rebase -i HEAD~1000
A text editor (the default one) will open and it will show all previous 100 commits. Delete the lines of the duplicated commits until you only have the commits you want. Save and exit.
At this point I don't expect you to have rebase conflicts.
3. Push the branch
Just push the branch upstream:
> git push origin fixing-duplicates
4. Check if the branch is ok
Give the branch a look and check if this is really what you want. if it is, just run:
> git push origin fixing-duplicates:master -f
If your GitHub instance prevents force pushing to the default branch, change the default branch to fixing-duplicates
and run the command again. Then just switch the default branch back to master
.
Let me know if this helped.