whatf
whatf

Reputation: 6468

Unmerge a git branch, keeping post-merge commits

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?

Upvotes: 40

Views: 31736

Answers (1)

Justin ᚅᚔᚈᚄᚒᚔ
Justin ᚅᚔᚈᚄᚒᚔ

Reputation: 15359

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

Upvotes: 78

Related Questions