Avoid unnecessary cherry-picks by creating new-branch directly at C, and then simply rebase master to remove commit C:
On master:
git branch new-branch sha1-of-C
git rebase --onto sha1-of-C^ sha1-of-C master
The second command deletes C from master by rebasing master
("branch" in the git-rebase man page) commits starting from sha1-of-C
("upstream") onto the commit before sha1-of-C
.
Or you can do the rebase interactively if that second command is too confusing:
git rebase -i sha1-of-C^
On the interactive rebase, simply delete commit C, save and quit.
During rebasing, if git complains about merge conflicts, resolve them, git add
, and git rebase --continue
. You would have to resolve these conflicts regardless of the method you choose.
cherry-pick
with arebase -i
in order to remove the other commit, but I wouldn't recommend deleting it entirely.