249

I have 2 branches, master and dev.

I am on dev branch and I want to cherry-pick 1 commit from master to dev. So I did

$ git cherry-pick be530cec7748e037c665bd5a585e6d9ce11bc8ad
Finished one cherry-pick.

But when I do git status and gitx, I don't see my commit be530cec7748e037c665bd5a585e6d9ce11bc8ad in git history.

How can I see my commit in the dev branch?

Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129
michael
  • 106,540
  • 116
  • 246
  • 346

2 Answers2

414

When you cherry-pick, it creates a new commit with a new SHA. If you do:

git cherry-pick -x <sha>

then at least you'll get the commit message from the original commit appended to your new commit, along with the original SHA, which is very useful for tracking cherry-picks.

Paolo
  • 21,270
  • 6
  • 38
  • 69
CanSpice
  • 34,814
  • 10
  • 72
  • 86
  • 57
    the '-x' is to append a line to the message that indicates where the commit was cherry-picked from. Useful only for public branches, not so much when cherry-picking from a local (private) branch to a public branch. – Dinesh Kumar Nov 01 '18 at 02:02
  • the "-x" is optional though. – Shady Smaoui Jul 05 '23 at 00:24
13

If you're an IntelliJ user, it's pretty simple. Here, I am cherry-picking a commit from master branch to give-me-commit-branch. Note a few points in the below pic:

  • destination: The current checkout branch is give-me-a-commit-branch. Denoted by tag icon.
  • source: The selected master branch whose commit logs are displayed on the right side is the source of the commit.
  • searching ability: Using the search (lens icon) option, we can find the revision number.
  • multiple-selections: At a time, we can select multiple commits and cherry-pick them at one go!

This is easy-to-use and transparent.

enter image description here

Saurav Sahu
  • 13,038
  • 6
  • 64
  • 79