# let's assume you want to rebase on master git checkout master git pull # save your branch containing the merge commit git checkout ${BRANCH_CHANGES} git branch ${BRANCH_CHANGES}-bak # add another merge on top git merge master # fix conflicts if needed, git add, git commit. # let's make a new clean branch now git checkout master git checkout -b ${BRANCH_CHANGES}-new # re-do the merge of the commit that you were trying to merge in your branch git merge ${TARGET_COMMIT} # (or: tools/libav-merge-next-commit merge) # now you have all your conflicts again, you can commit them in that state if # you're planning to squash the conflict fixes changes withing the merge commit # later git add . git commit --no-edit # and now fetch the content of the branch with all your conflict solved # (which also includes the necessary changes so it is clean against master) on # top: git checkout ${BRANCH_CHANGES} -- . git add . # reuse last commit message git commit -c ${BRANCH_CHANGES}-bak --no-edit --amend # replace the old branch git branch -D ${BRANCH_CHANGES} git branch -m ${BRANCH_CHANGES} # eventually delete the backup if everything went well git branch -D ${BRANCH_CHANGES}-bak