Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git cherry-pick -x default

Tags:

In the man page for git cherry-pick:

...

-x
    When recording the commit, append a line that says "(cherry picked
    from commit …)" to the original commit message in order to indicate
    which commit this change was cherry-picked from. ...

-r
    It used to be that the command defaulted to do -x described above,
    and -r was to disable it. Now the default is not to do -x so this
    option is a no-op.

...

Is there a config setting to locally set the default back to -x, and allow -r to disable it? I couldn't find one, but I may have missed it.

like image 961
vergenzt Avatar asked Jun 22 '12 14:06

vergenzt


People also ask

Does git cherry pick automatically commit?

git cherry-pick is a powerful command that enables arbitrary Git commits to be picked by reference and appended to the current working HEAD. Cherry picking is the act of picking a commit from a branch and applying it to another. git cherry-pick can be useful for undoing changes.

How does git cherry pick work?

Cherry-picking works by figuring out the patch—that is, the changes—introduced by a given commit and then applying that patch to the current branch. That might result in conflicts if the commit you decided to cherry-pick builds on changes introduced by an earlier commit you didn't cherry-pick.


2 Answers

Short of making an alias for git cherry-pick -x, no, this is not possible.

(Fun fact: The default was changed in commit abd6970.)

like image 197
vergenzt Avatar answered Oct 05 '22 00:10

vergenzt


add this alias to your ~/.gitconfig by running:

git config --global --replace-all alias.pick "cherry-pick -x"

You can then simply run:

git pick abc123

You may replace the choice of "pick" to whatever word makes sense to you.

like image 25
Jeff Dag Avatar answered Oct 04 '22 23:10

Jeff Dag