How do I undo a change that was committed locally and pushed to the server?

I performed a manual merge recently.  The merge was committed and pushed to the server, but now we've found a major problem with it.  (The problem file is the storyboard and manually undo-ing the changes will not be trivial.)

Is there a simple way to undo the change on the server and then pull the clean code back to my machine?

1 answer

1 accepted

The safest way to do this is to right-click the bad commit, and choose "reverse commit". This will create a new commit that performs the opposite changes compared to the one you selected to reverse.

Commit the reversed changes (if SourceTree doesn't commit automatically), and push to the remote.

Git also allows you to re-write the history to remove that commit from the branch entirely, but this is generally considered bad practice because it can cause problems for the local repositories of other team members.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

542 views 1 2
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you