Reputation: 1496
How can I undo a merge when I have already pushed to master after merge? Here are my steps:
git add -A
git commit -m "some message"
git fetch origin master:master
git rebase master (resolve merge conflicts)
git push -f origin my local branch
I want to go back to the state where i was at step 2
Upvotes: 0
Views: 1733
Reputation: 7110
You force pushed, meaning you overwrote the changes on a remote. Your computer can't fix it; however, if there is another computer with a local copy before you force pushed, you can force push from that computer and overwrite your force push.
Git's push --force is destructive because it unconditionally overwrites the remote repository with whatever you have locally, possibly overwriting any changes that a team member has pushed in the meantime. - Atlaissan Git Resource
There are some cases where checking out to an old commit and then force pushing that might work, but I suspect that probably won't work in your case because you had to force push your changes.
Upvotes: 5