Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I undo a sourcetree pull from branch into master

Scott Goldberg
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 17, 2019

I have only used Sourcetree for a single branch. Now I have been working on a dev branch on a laptop while I was away. When I got back to my desktop, I didn't know that I had to checkout the dev branch (again, sorry for being such a newb) and I did a pull thinking it would know to create the dev branch, and it all went into the master. So now my master branch and dev branch look exactly the same. I now have checked out the dev branch to the desktop, but the master and the dev branch still look the same in terms pf commits. So do I now just 'remove' the commits to master?

 

TIA,

Scott

1 answer

0 votes
JustaResource June 19, 2019

It sounds like you are wanting to do a hard reset - effectively 'delete' the merge with master that happened.

If that is so, there are two ways I can think of.

You can tell git/Sourcetree to reverse the merge commit - to undo the changes introduced from the merge, but creating a new commit - still showing that a merge with master happened.

Or you can hard reset your working branch to a previous commit if you want it to look like the merge never happened. Make sure you pick the correct commit you want to reset to.

*Note if you have already pushed this unwanted commit to a remote, you will have to force push after your hard reset to overwrite the branch on the remote. Otherwise git/Sourcetree will not allow you to push your changes because it will say that your branch doesn't match the remote and needs to be merged with it - and if you did that, it would re-introduce the commit you don't want.

Reverting the commit would be the more mainstream/recommended way of using git, rather than a hard reset. But I find myself doing a hard reset and force push from time to time.

Hard reset.gif

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events