Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I undo a sourcetree pull from branch into master


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?




1 answer

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
Community showcase
Published in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

7,200 views 5 14
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you