2013-03-20 84 views
2

如何在簽出第一次提交後列出所有的git分支?第一次提交Git結賬

例如

git log --oneline 

顯示我所有的分支:

06c4b5c Version 3 of Hello World 
efa167f Version 2 of Hello World 
47a33c8 Hello World 

如果我看看我的第一次提交

git checkout 47a33c8 

顯示此消息

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout...

那麼,如果我這樣做:

git log --oneline 

只有一次提交現在顯示:

47a33c8 Hello World

我的問題是,如果我不知道HEAD的是在06c4b5c位置原本,如何在檢查完第一次提交後我是否返回到這個位置?

而且,當我嘗試籤06c4b5c

git checkout 06c4b5c 
+1

對於第二個問題,請嘗試通過其完整提交散列(在'git log'中)檢查它。 – nneonneo 2013-03-20 00:49:15

回答

6

您可以使用git reflog看到你在哪裏之前,我得到這個錯誤

Error: pathspce '06c4b5c' did not match any file(s) known to git.

。你會看到一個條目,如

checkout: moving from master to 47a33c8 

只是做git checkout master返回到該分支。

要列出所有分支,請使用git branch -l

+0

+1非常感謝。有效。 – Anthony 2013-03-20 00:49:57