Search code examples
gittortoisegit

How can i Cherry pick a commit of another branch using TortoiseGit without committing?


I can cherry pick a commit using bash

git cherry-pick -n <HASH>

But is there any way to do that by using TortoiseGit?


Solution

  • Checkout the branch on which you want to cherry pick the commit it. Then

    • open the Log Dialog,
    • scroll to the commit (maybe you have to select "all branches" in the lower left or use the top-left blue branch name to select the source branch and filter the list for the commit hash),
    • open the context menu on the commit and
    • select "Cherry pick this commit...".

    Now you basically have two options as the -n option is not directly available in TortoiseGit.

    1) Change the cherry-pick type from "Pick" to "Edit", start the cherry-pick and then, check the "Edit commit" checkbox, keep the commit dialog open, do your changes and then commit and finish the cherry-pick.

    2) Finish the cherry pick and then

    • go to your HEAD commit,
    • select the parent commit of the just cherry picket commit,
    • and choose "Reset" on the context menu and
    • select mixed.

    cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-cherrypick.html