Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you `git cherry-pick --continue` with `--no-verify`?

How do you git cherry-pick --continue with --no-verify since --no-verify is not a valid option. git cherry-pick --no-commit --continue does not work since those two parameters are mutually exclusive.

like image 628
Archimedes Trajano Avatar asked Dec 09 '20 20:12

Archimedes Trajano


People also ask

How do you continue cherry pick after conflict?

If you look at the console, "fix conflicts and run "git cherry-pick --continue." When fixing conflicts the normal way (without the cherry-pick), the console will mention to commit (after the conflicts have been fixed).

How do you cherry pick a whole branch?

In your case you can simply checkout master branch and then cherry-pick all the commits from any branch that you wish ( cherry-pick supports ranges so you can specify start and end commit instead of listing all the commits). This way you can control the way your commits will appear in the desired branch.


3 Answers

If your cherry-pick (without --no-commit) had merge conflicts and you want to --continue after solving them, you can temporarily disable git hooks for the current repo with:

$ git config core.hooksPath # Print current setting
$ git config core.hooksPath '/dev/null/'

After you're done, depending on whether core.hooksPath was set before, you can either restore the previous setting:

$ git config core.hooksPath '/some/previous/path'

or unset it again:

$ git config --unset core.hooksPath
like image 184
mickdekkers Avatar answered Oct 22 '22 18:10

mickdekkers


--no-verify is an option for the commit command, not cherry-pick.

However what you can do is to use the --no-commit flag for your cherry-pick, then git commit --no-verify is fine to conclude the cherry-pick.

like image 9
Romain Valeri Avatar answered Oct 22 '22 20:10

Romain Valeri


To expand on @mickdekkers answer, I added the following function to my ~/.bashrc --

git() {
    if [[ $@ == *"--no-verify"* ]];
    then
        command git -c core.hooksPath=/dev/null "$@ | sed 's/--no-verify//'";
    else
        command git "$@";
    fi;
}

This sets the hookpath to null any time the --no-verify flag is used.

like image 1
Teejay Bruno Avatar answered Oct 22 '22 19:10

Teejay Bruno