Why does git checkout “origin/branch-name” lead to “no branch”, in git 1.5?
The problem seems to arise from my lack of experience with git 1.5, as this works just fine if I try on a system with 1.7. Why do I end up on “no branch”, and more importantly, what can I do to get to the HEAD of “interesting_branch”?
$ git --version git version 188.8.131.52 git clone firstname.lastname@example.org: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
2 Solutions collect form web for “Why does git checkout “origin/branch-name” lead to “no branch”, in git 1.5?”
You need to create local tracking branch manually:
$ git checkout -b feature-cg-interesting_branch origin/feature-cg-interesting_branch
You should do it for each remore branch except
origin/master is not a local branch, and therefore it leaves your repository in detached head state (like when you check out a tag or a commit by its hash). Remote branches are there to keep track about what the last state of each branch the last time synced with the remote repository.
You need to create a local branch when you want to develop that branch further.