开发者

why does git cherry-pick create a different checksum?

In the following session, why does the result of git cherry-pick not have the same checksum as the copied commit? It has the same comment, author, date, and parent. What else is in the checksum that I am not accounting for?

Thanks.

~$  mkdir tmp
~$ cd tmp/
~/tmp$ git init
Initialized empty Git repository in /home/sinclairs/projects/tmp/.git/

~/tmp$ echo "asdf" >asdf
~/tmp$ git add asdf
~/tmp$ git commit -m asdf
[master (root-commit) 7d0aaa3] asdf
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 asdf

~/tmp$ echo "fdsa" >asdf
~/tmp$ git commit -a -m asdf2
[master b392367] asdf2
 1 files changed, 1 insertions(+), 1 deletions(-)

~/tmp$ git log --format=oneline
b3923677106db9371faf55ed2cb8c7d06f586f7f asdf2
7d0aaa3937de390b7a119c73dbf9428126c1bac5 asdf

~/tmp$ git checkout -b mybranch HEAD^
Switched to a new branch 'mybranch'

~/tmp$ git cherry-pick master
Finished one cherry-pick.
[mybranch ca92f66] as开发者_C百科df2
 1 files changed, 1 insertions(+), 1 deletions(-)

~/tmp$ git log --format=oneline
ca92f666cc53715c6b5ae2975b938275e0d20f73 asdf2
7d0aaa3937de390b7a119c73dbf9428126c1bac5 asdf


From the documentation :

git cherry-pick master
    Apply the change introduced by the commit at the tip of the master branch and create a new commit with this change.

The new commit date is different.


Author date is the same but commit date is different.

And you can use this to actually see the difference.

git cat-file -p b3923677106db9
git cat-file -p ca92f666cc5371

Author line is the same, committer line date is different.


Even if you would adjust the commit date (which is possible) the tree and parent are different and you cannot change them!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜