2013-08-07 38 views
2

這些[email protected]{0}[email protected]{1}是什麼意思?是不是HEAD應該是一個指向單個提交的標記?爲什麼它在兩個時間都顯示?HEAD @ {n}在git reflog的輸出中意味着什麼?

git reflog 
97df263 [email protected]{0}: commit: I just made my first change to this file. Yay! 
4333289 [email protected]{1}: clone: from https://github.com/tswicegood/mysite 
+2

請研究['gitrevisions(7)'manual](https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html),它解釋了所有這些'〜'和'''有趣的人物。 – kostix

+0

可能的重複[在〜和^在git中有什麼區別](http://stackoverflow.com/questions/14733687/whats-the-difference-between-and-in-git) – kostix

+0

@kostix爲什麼?這個問題與這兩個角色無關。 OP在詢問'@ {n}'。 – Ajedi32

回答

1

在這種情況下,@{n}部分是「能走多遠回顧歷史」。 [email protected]{0}HEAD的最新值,並且[email protected]{1}的值是HEAD之前最新的值存儲在其中的值。有關更多信息,請參閱git-rev-parse手冊中的「指定修訂」。

2

在原來的海報的例子:

$ git reflog 
97df263 [email protected]{0}: commit: I just made my first change to this file. Yay! 
4333289 [email protected]{1}: clone: from https://github.com/tswicegood/mysite 

[email protected]{n}簡單地意味着第n個先前的位置的HEAD

更一般地,<reference>@{n}語法速記意味着「基準/分支的第n個先前的位置」,正如我在my answer to What does the 「at」 @ sign/symbol/character mean in Git?狀態。所以,你可以使用這個語法與任何參考/分支,例如:

official Linux Kernel Git documentation for specifying Git revisions解釋:

<refname>@{<n>},例如[email protected]{1}

一個ref,後面加上後綴「@」和一個大括號(例如「{1}」,「{15}」)中包含的序數說明,指定該ref的第n個前值。例如,「master @ {1}」是主站的前一個值,而「master @ {5}」是主站的第5個前一個值。該後綴只能在ref名稱後面立即使用,並且ref必須具有現有日誌(「$ GIT_DIR/logs /」)。