2012-02-28 101 views
2

這個問題似乎是由於我對git 1.5的經驗不足而產生的,因爲如果我嘗試使用1.7版本的系統,這種方式工作得很好。爲什麼我最終選擇了「無分支」,更重要的是,我能做些什麼才能到達「interesting_branch」的頭部?爲什麼git checkout「origin/branch-name」在git 1.5中導致「no branch」?

$ git --version 
git version 1.5.6.5 
git clone [email protected]:path/to/repo 
Initialized empty Git repository in some/local/path/.git 
<snip> 
cd path 
git branch -a 
* master 
    origin/HEAD 
    origin/develop 
    origin/feature-cg-interesting_branch 
$ git checkout feature-cg-interesting_branch 
error: pathspec 'feature-cg-interesting_branch' did not match any file(s) known to git. 
$ git checkout -- feature-cg-interesting_branch 
error: pathspec 'feature-cg-interesting_branch' did not match any file(s) known to git. 
$ git checkout origin/feature-cg-interesting_branch 
Note: moving to "origin/feature-cg-interesting_branch" which isn't a local branch 
If you want to create a new branch from this checkout, you may do so 
(now or later) by using -b with the checkout command again. Example: 
    git checkout -b <new_branch_name> 
HEAD is now at 6534d1d... [Commit message] 
$ git branch 
    * (no branch) 
    master 

回答

5

您需要手動創建本地跟蹤分行:

$ git checkout -b feature-cg-interesting_branch origin/feature-cg-interesting_branch 

你應該做的每一個遙遠而明亮的分支除外master

1

origin/master不是本地分支,因此它留下你的資料庫在分離的頭部狀態(例如,當您通過其哈希簽出標籤或提交時)。遠程分支可以跟蹤上一次與遠程存儲庫同步的每個分支的最後狀態。

當您想要進一步開發該分支時,您需要創建本地分支。

相關問題