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:
Now, how do I cherry pick commit C1 of branch A into branch B? I am using Gerrit, GitBlit and EGit in eclipse.
The git cherry-pick is a very useful command. It takes changes from a specific commit and applies them to your current branch in a new commit. As a consequence, git cherry pick does not alter your current Git history : instead it adds commits to it.
Go to either the git log or the GitHub UI and grab the unique commit hashes for each of the commits that you want. "Cherry pick" the commits you want into this branch. Run this command: git cherry-pick super-long-hash-here . That will pull just this commit into your current branch.
Cherry-picking in TortoiseGit is invoked from the Revision Log Dialog. Within this dialog, select the commit(s) to cherry-pick, then right-click on one of the selected commits to pop up the context menu. Select Cherry Pick this commit... (or Cherry Pick select commits... if more than one commit is selected).
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'.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With