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 Edited

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

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

Sourcetree for Windows - CVE-2019-11582 - Remote Code Execution vulnerability

A vulnerability has been published today in regards to Sourcetree for Windows.  The goal of this article is to give you a summary of information we have gathered from Atlassian Community as a st...

4,970 views 0 12
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