簡體   English   中英

為什么在git 1.5中git checkout“ origin / branch-name”導致“ no branch”?

[英]Why does git checkout “origin/branch-name” lead to “no branch”, in git 1.5?

這個問題似乎是由於我對git 1.5缺乏經驗而引起的,因為如果我嘗試使用1.7的系統,這很好用。 為什么我會以“無分支”結尾,更重要的是,我該怎么做才能到達“ interesting_branch”的頭?

$ git --version
git version 1.5.6.5
git clone git@git.example.com: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

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

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

您應該對除master以外的每個remore分支都這樣做

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM