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

Removing a bad merge on local and remote repository?

Michael_Heins July 2, 2014

I'm working on a github branch off of master. Recently after merging master into my branch I did a commit and push to the remote repository, then discovered something bad happened during the merge. I don't know how to get past the bad merge that's now in the remote. I can reset my local repository to my previous good commit on my branch to continue work, but when I want to commit and push up to the remote repository, I can't because the remote is ahead of my local (by the bad commit). I can't pull from the remote because the bad commit messes up my local so I can't build. How do I recover from this?

3 answers

0 votes
Michael_Heins July 8, 2014

Thank you both for your suggestions. I ended up figuring out how to repair the code from the bad commit, and then checked in the repaired code.

0 votes
Balázs Szakmáry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2014

You have two options:

  1. Rewrite history: Do the changes as described and force push to the server (SourceTree does not seem to be able to do this, you need something else, e.g. cmd or GitExtensions.)
  2. Leave history as it is and fix the code: Revert the bad commit (since it is a merge commit, you need to either create a custom action in SourceTree to have the -m switch or do it from another client), push it to the server and commit on top of that as usual.
0 votes
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2014

You probably won't be able to do this from the SourceTree UI, but you can definitely push the fix using the command line. I think the parameter is --force, but I would recommend a quick google search to confirm.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events