2014-02-10 48 views
0

所以我在一個獨立的頭上,我做了一些改變。我現在在一個不同的頭上,我如何返回到我的獨立頭部更換線程的主人?回到受委託的獨立頭(GIT)

感謝

$ git commit -m "Connect Users to Fitbit accounts" 
[detached HEAD b3b8249] Connect Users to Fitbit accounts 
17 files changed, 159 insertions(+), 3 deletions(-) 

回答

2

可以git checkout提交:

git checkout b3b8249 

分行基本上是一個名爲提交和git checkout作品的一切是可以解決的承諾(承諾,分支,標籤, the reflog),不僅有分支機構。


正如我所提到的引用日誌:如果你不記得EXAKT提交哈希引用日誌是要走的路:

[[email protected]/tmp/test (5d0f65b...)]git checkout master 
Switched to branch 'master' 
[[email protected]/tmp/test master]touch b 
[[email protected]/tmp/test master]git add b 
[[email protected]/tmp/test master]git commit -m "Add b" 
[master 9bf5987] Add b 
0 files changed 
create mode 100644 b 
[[email protected]/tmp/test master]git reflog 
9bf5987 [email protected]{0}: commit: Add b 
5d0f65b [email protected]{1}: checkout: moving from 5d0f65ba749c8f39773c4edb16ab40c5c58501d4 to master 

第一欄會告訴你其中頭部指向並且你可以通過檢索舊的狀態[email protected]{N}git checkout

[[email protected]/tmp/test master]git checkout [email protected]{1} 
Note: checking out '[email protected]{1}'. 

... 

HEAD is now at 5d0f65b... Add a 

的引用日誌將你的頭保存在某些情況下,它可以讓你幾乎檢索任何丟失的東西,例如在復位失敗,在重置等提交失敗。

+2

您也可以給reflog-only或僅ID提交一個名稱(分支或標籤名稱),例如'git branch new-branch 5d0f65b'或' git標籤臨時標籤5d0f65b'。像'HEAD @ {1}'這樣的名稱只是編寫提交的SHA-1的另一種方式,所以這也適用於那些:'git branch new-branch HEAD @ {1}',例如。 – torek