It depends what you mean by "f".
Perhaps it would help to have a clearer mental picture of what a cherry-pick does? It copies a commit, giving the copy a different hash. So there are now two commits with the same message, but with different hashes.
It also depends on your understanding of git diff
. It may be that the phrase git diff <some-commit>
needs some clarification; perhaps what you think it does is not what it really does.
First, you cannot really be saying git diff f
, because f
is not the name of a commit. So what are you really saying? Which hash are you specifying? Are you saying
git diff <the-original-f>
or are you saying
git diff <new-copy-of-f>
??
If you git diff <the-original-f>
, you should see something in response.
But if you git diff <new-copy-of-f>
, meaning the copy of f
that is now on the end of master
, naturally git diff
will be empty, because you are comparing two identical things.
Why? Well, that brings me to my second point. The simple command git diff <commit>
compares that commit to the working tree. Well, when you cherry pick, the working tree is updated to match the commit that you just cherry picked. So there is indeed no difference.
To demonstrate, I constructed your graph in real life. Here's the log:
* e09ed05 (HEAD -> feature) g
* 534df94 f
* d8b09e2 e
| * a01de45 (master) d
| * 9c56924 c
|/
* 7f2fdd8 b
* e7a240b a
As you can see, feature
branches off from master
at b
, just as in your first graph. Okay, now I will do what you did: I checkout master
and cherry-pick 534df94
(that is my "f"). And we get this:
* d9cc51a (HEAD -> master) f
* a01de45 d
* 9c56924 c
| * e09ed05 (feature) g
| * 534df94 f
| * d8b09e2 e
|/
* 7f2fdd8 b
* e7a240b a
So now, as you see, there are two "f" commits: the original, 534df94
on feature
, and the new copy, d9cc51a
on the end of master
.
Well, if I now git diff 534df94
(the old "f"), there is a difference. But if I git diff d9cc51a
(the new "f"), there is no difference and no response. And that is correct and expected. My working tree is identical to commit d9cc51a
. This is exactly like saying git diff master
, and I am on master
; master
is HEAD
(as you can see from the log).