e40 e40 - 4 months ago 27
Git Question

How can I tell, from a script, if "git cherry-pick" fails?

If the cherry-pick fails due to a merge conflict, it just returns an exit status of 0.

Please don't tell me about

. I need to detect, in a script, if the original cherry-pick command fails.

Using git version on CentOS 7.2.

EDIT: my script was doing the cherry-pick in an
if !
and I didn't exit properly in the
clause with a non-zero exit. Sorry for the noise.


$? is the return code for a process run in bash.

$ ls /dev/null/foo
ls: /dev/null/foo: Not a directory
$ echo $?