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

I am writing a script to migrate git repositories. In case of cherry capture conflicts, I run

git add . git cherry-pick --continue 

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

You can also welcome obsolete terminal hacks;)

+8
source share
3 answers

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

However, to skip editing the commit message, you can simply set your editor to a command that does nothing and reports success. Ideal for 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 GIT_EDITOR , VISUAL or EDITOR environment EDITOR ; and in fact, if any of them are installed, you should use them, not core.editor , because the sequence: use $GIT_EDITOR if it is set; else use $VISUAL if it is installed; else use $EDITOR if it is installed; else use core.editor if it is installed; else use everything that is built into this version of Git.)

+12
source

You can use:

 git cherry-pick <sha1> --no-commit 

after resolving the conflict, you can pass it from the script.

Of course, you can set the cherry pick strategy parameters to automatically resolve conflicts by accepting code from our / them

Without this, you will get standard git conflict markup

 +<<<<<<< HEAD some code +||||||| parent of 4d64ec6... test commit + first version code +======= + second version code +>>>>>>> 4d64ec6... test commit 
0
source

Let's say we need a specific SHA commit, but we don’t want git triggers:

 # skips pre-commit and commit-msg hooks git cherry-pick -n SHA 

If there are conflicts, then resolve:

 git mergetool 

Now, instead of continuing with git cherry-pick --continue , you should add the modified files and continue:

 git add . git commit -n 

The same window will appear as when using git cherry-pick --continue , then you can edit the git cherry-pick --continue or leave it unchanged.

The difference from cherry-pick -n is that the selected commit will be created as the user executing cherry-pick , and not as the original author.

0
source

Source: https://habr.com/ru/post/1259966/


All Articles