114

How do I run the cherry pick command using TortoiseGit UI?

Simon East
  • 46,575
  • 14
  • 130
  • 124
antonjs
  • 13,120
  • 11
  • 61
  • 86

3 Answers3

168
  1. Open the log in a repository with the target branch checked out.
  2. Use the top-left blue branch name to select the source branch.
  3. Select the commit(s) you want.
  4. Right click and select Cherry Pick this commit.
Oliver Bock
  • 4,185
  • 3
  • 33
  • 56
vpatil
  • 2,962
  • 1
  • 15
  • 9
  • 53
    To see the log for another branch, click on the blue branch name on the top left of the log window. – kichik May 17 '13 at 23:13
  • 4
    I know this is a good answer, but I have no cherry pick option on right click, no matter what branch I select – PandaWood Dec 12 '13 at 04:59
  • 1
    @PandaWood maybe your current working branch is on a detached HEAD? If that's the case, you just need name the current branch. "git checkout -b " or whatever the TortoiseGit option is... – Digikata Mar 10 '14 at 22:48
  • 6
    another common reason no cherry pick option on right click appears, is that the branch you're on already has that commit – vazor May 08 '15 at 21:09
  • 1
    Open "Show log", then I activated "All branches" and then I got visible all branches (with their commit history) and then the possibility to cherry pick got active as well (as noted before, I got a commit which wasn't present in the current branch). – st6mm Oct 08 '15 at 14:11
  • AFAIK you can cherry pick a commit, but not a file in the commit. I came from Perforce where it's possible, so I kept right clicking on a file in a commit (bottom pane on Show Log) instead of right click on whole commit (upper pane). – prostynick May 19 '16 at 09:38
  • 1
    The branches involved in the cherry picking aren't made very clear. Cherry picking copies a commit from one branch to another. The top left branch shown is the _source_ branch, but the target branch is implicit. It's whatever you currently have checked out. Confusingly, TortoiseGit appears to offer to cherry pick even if source and target branch are the same (!) – MSalters Sep 27 '16 at 08:31
17

Considering 'release' branch is required to cherry-pick from 'master' branch, follow the steps as provided below:

Step 1: Checkout 'release' branch

enter image description here

Step 2: Click TostoiseGit -> Show log

enter image description here

Step 3: Filter Source Branch Commits to be Cherry-picked

On the Log Messages window, select the source branch from where the commits will be Cherry Picked (i.e. 'master' branch in this example). The branch selection can be done from top left of the 'Log Messages' window (as shown below)

enter image description here

Step 4: Select the Commits to be Cherry-picked

Finally select the commits and right-click the context menu to cherry-pick them.

enter image description here

Ashraf Alam
  • 3,010
  • 30
  • 31
  • 2
    for Step 1, I switch branches by going Right-click -> TortoiseGit -> Switch/Checkout – McCoy Feb 27 '18 at 19:02
  • After clicking on "Cherry Pick selected commits", click on continue, merge the conflict, if any and then click on commit. After doing all this, don't forget to push the code in corresponding branch (here release). – S Kumar Apr 18 '19 at 13:53
6

The above answers are also correct and I am just simplifying it.

If you want to cherry pick from one branch to another (for example: Branch_18.1 to Branch_18.4)

  • Go to Branch_18.4 folder(repo)
  • Right click and select show log, it will open a log dialog window
  • In this window, at top left Corner click on Current branch Hyperlink (i.e. Branch_18.4)
  • Now select the branch from which you want to cherry pic (i.e. Branch_18.1)
  • Now select and right click on the commit which to be cherry picked and select Cherry pick selected commits.
  • Now It may ask you to stash your changes if you have any changes in your working tree then in that case click on "YES" .
  • Now Before pushing cherry picked changes, pull and then Push.
  • 1
    Welcome to StackOverflow! In case you just want to improve existing answer, it's usually better idea to suggest an edit to it (by clicking `edit` under answers content) – Arion Sep 07 '18 at 13:41