2011-03-01 21 views
1

在以下會話中,爲什麼git cherry-pick的結果與複製的提交沒有相同的校驗和?它有相同的評論,作者,日期和家長。校驗和中還有什麼我沒有考慮的?爲什麼git cherry-pick會創建一個不同的校驗和?

謝謝。

~$ 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] asdf2 
1 files changed, 1 insertions(+), 1 deletions(-) 

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

回答

3

作者日期相同,但提交日期不同。

你可以使用它來真正看到差異。

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

作者行相同,提交者行日期不同。

+0

是的。在這個例子中,兩者的父代是7d0aaa3937de390b7a119c73dbf9428126c1bac5。 – 2011-03-01 09:54:43

5

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. 

新的提交日期是不同的。

2

即使你要調整提交日期(這是可能的),樹和父母是不同的,你不能改變它們!

相關問題