I accidently pushed a feature branch to the remote master. Now I want to revert the master to the previous commit. When I select 'Revert current branch to this commit' only the local branch is reverted, and because the remote master is 55 ahead (accidental push) I cannot push the just reverted local master to the remote.
When looking into this issue on SO and Google, I found that many people use force push using the command line. But since I'm using Source Tree I'd like to come up with a way that actually uses Source Tree.
I also found the rebase option, but I can't seem to find a step-by-step tutorial..
Any ideas?
Assuming the just want to get rid of the last 2 commits, then you can right click on 3rd from last commit and choose "Reset current branch to this commit" and then decide if you want to keep any of the changed files or not, if not select the 'Hard' reset and your local repo will return to that state, before you ...
When you push a commit, the safest way to revert it (rather than forcing the push with -f) is to use the revert
function, so a new commit is created on top of your previous commit.
This is possible to do using Sourcetree, right clicking in the commit that you want to revert, and selecting "Reverse commit...".
You would need to do this for each commit you want to revert, in reverse order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With