16

Suppose I have a new system with no git history and I take a fresh checkout of branch A. Branch A already has a commit C1 which I did yesterday from some other system. Now I want to cherry-pick this commit C1 in branch B. Issue:

  1. If I take checkout of branch A and go to commit C1 (in history in Git view) and click 'cherry pick', it says do you want to cherry pick in branch A? So, there is no discussion of branch B here.
  2. If I take checkout of branch B it will not show commit C1 at all.

Now, how do I cherry pick commit C1 of branch A into branch B? I am using Gerrit, GitBlit and EGit in eclipse.

Farrukh Chishti
  • 7,652
  • 10
  • 36
  • 60

6 Answers6

16

Qualatar comment is a little outdated, here is how to show all branches in 'Show History' in 'Version: Luna SR2 (4.4.2)' so that you can 'right click > Cherry Pick'.

how to see all commits in Eclipse IDE EGIT to cherry pick

Daniel Sokolowski
  • 11,982
  • 4
  • 69
  • 55
12

I'm not familiar with the GUI you are using in particular, but the concept you are describing is perfectly acceptable in git.

To cherry-pick a commit from branch A to branch B, use the following command line commands:

git checkout branchB
git cherry-pick hashOfC1

There should be a sort of 'view all branches' mode in the GUI you are using so that you can see commit C1 while having branch B checked out, but if not, the above commands are simple enough to execute.

Ben Siver
  • 2,758
  • 1
  • 25
  • 42
  • I guess there commands are for git bash. Can I do this using egit from eclipse? – Farrukh Chishti Apr 01 '15 at 14:55
  • 3
    The [EGit user guide](https://wiki.eclipse.org/EGit/User_Guide#Cherry-pick_Introduction) has a really good example on how to cherry-pick from their UI. – Ben Siver Apr 01 '15 at 14:57
  • 4
    GOT IT !!! The culprit was a small cylinder in upper right corner of history view saying "Show all changes in repository containing the selected resource". That needs to be selected to show commits of all branches. However, this leaves an open question. When I checkout branch B does it pull all the details of all the branches to update this history tree? – Farrukh Chishti Apr 01 '15 at 15:05
10

goto "Team Synchronizing", right click on project to display the menu. select show In -> History. This will display History tab with changesets.

enter image description here history tool bar

when you click on icon with 2 arrows downwards then you will see all the changes even those not from your branch. Right click on changeset that you want to cherry pick and then select Cherry Pick.. option as shown in the picture

enter image description here

3

Step : Pick From other Branch

Switch your current branch

enter image description here

  1. Click / Tick / Show all Branch
  2. Select and right click -> cherry pick the commit

enter image description here

  1. continue until finish.
  2. Right click project and push commit on current branch.
Farid Blaster
  • 974
  • 1
  • 9
  • 23
3

To Cherry pick onto another branch in Eclipse eGit follow these steps:

  1. Checkout a branch where you would to do cherry pick a commit to.
  2. Open History View.
  3. In the toolbar click on "Change which commits to show" to show All branches matching the configured ref filters.
  4. Select a commit and open context menu and press Cherry pick.
Shadyar
  • 709
  • 8
  • 16
1

If you are using Eclipse or STS,

  • Navigate to Windows -> Show View -> History to open the
    history view.
  • Select the branch icon (below image) on the right top of the history view to see commits from all the branches enter image description here
  • Navigate to the commit Id you are interested in, right click and
    select Cherry-Pick
markiv
  • 31
  • 3