2013-03-20 103 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