Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git cherry-pick --continue, '--no-edit' option?

Tags:

I'm writing a script for migrating git repos. On cherry-pick conflicts I run

git add .
git cherry-pick --continue

This brings up vim, prompting me to save the commit message and freezes the script. I am looking for a command-line option like --no-edit or --porcelain to get around this.

Ugly terminal hacks might be welcomed as well ;)

like image 604
Harald Nordgren Avatar asked Nov 18 '16 12:11

Harald Nordgren


People also ask

How do I edit a cherry pick commit?

Change commit message when cherry-picking To change the commit message when cherry-picking, use “git cherry-pick” with the “-e” option. As illustrated in this example, your default editor will open and it will let you change the commit message.


1 Answers

As Zildyan said in his answer, you will need to resolve all the conflicts before doing git add. Therefore, you should not make this fully automated.

That said, to skip editing the commit message, you can simply set your editor to a command that does nothing and reports success. The ideal one on Unix-like systems is the true command. Hence:

git -c core.editor=true cherry-pick --continue

will do the trick. (You can also use any of the environment variables GIT_EDITOR, VISUAL, or EDITOR; and in fact, if any of those are set, you must use them rather than core.editor since the sequence is: use $GIT_EDITOR if that is set; else use $VISUAL if that is set; else use $EDITOR if that is set; else use core.editor if that is set; else use whatever is built in to this version of Git.)

like image 66
torek Avatar answered Sep 25 '22 15:09

torek