gitcherry-pick

How to add extra stuff to a cherry-pick?


When cherry-picking in git, I have often the situation that I want to add extra changes to it like a ChangeLog or NEWS entry.

When the cherry-pick stops with a conflict, then everything is fine: I am fixing the conflicts, add the extra bits, then git add, git cherry-pick --cont etc.

However when the cherry-pick does not come up with a conflict it gets annoying:

$ git cherry-pick -x <ref> # Passes fine
$ git reset --soft HEAD~1
$ git add ... # My extra bits
$ git commit -c HEAD@{1}

Is there a simpler way to make cherry-pick stop? I tried --no-commit but then I don't get the cherry-pick generated commit message and author.


Solution

  • No need for reset. Just add and amend:

    $ git cherry-pick -x <ref> # Passes fine
    $ git add ... # My extra bits
    $ git commit --amend --no-edit