40

Say there are two branches master and branchA.

I work on master, a friend on branchA. Once things are finalized, we merge branchA with master.

After several commits on the merged master, the client wants the work done on branchA removed, but NOT the commits done after the merge.

How can we do it?

1 Answer 1

78

Read through Pro Git - Undoing Merges.

Basically, you git revert the merge commit:

git revert -m 1 hash_of_merge_commit

You may end up with some conflicts that you'll have to manually unmerge, just like when merging normally.

Additional links:

  1. Git SCM - Undoing Merges

  2. Git Ready - Rolling back changes with revert

Sign up to request clarification or add additional context in comments.

4 Comments

please re-read the question, if possible give an objective answer.
Please re-read the answer, and the article linked. It explains, objectively, how to do exactly what you're trying to do.
@Justinᚅᚔᚈᚄᚒᚔ sounds like useful intel but the links are all broken; do you have a newer version of that Undoing Mergest post?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.