Search code examples
gitcherry-pick

force partial git cherry-pick?


When I'm doing a git cherry-pick and there's a conflict, git stops short of making the commit and allows me to resolve the conflict.
Is there a way to force this stop even if there are no conflicts?
The reason I want to do that is that I have a change I want to cherry-pick but I don't want all of the files it changes. Having it stop just before making the commit allows me to remove the file from the commit and then do git cherry-pick --continue without it

git cherry-pick --no-commit does something similar to what I want but not exactly.
If you do git cherry-pick --no-commit and then git commit the result is different than what you get if you do git cherry-pick, resolve a conflict and then do git cherry-pick --continue


Solution

  • Maybe you are searching for git cherry-pick --no-commit

    -n --no-commit

    Usually the command automatically creates a sequence of commits. This flag applies the changes necessary to cherry-pick each named commit to your working tree and the index, without making any commit. In addition, when this option is used, your index does not have to match the HEAD commit. The cherry-pick is done against the beginning state of your index.

    This is useful when cherry-picking more than one commits' effect to your index in a row.

    From here.