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 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

  • Merge git commit history
  • Ediff as git difftool
  • How do I merge a single commit?
  • Get a preview of “git add -u”?
  • git revert changes and cancel pull request
  • why does it say “Your branch is ahead of origin/master by 857 commits” when I need to *pull* origin master
  • Can I get git log to print the history in reverse order?
  • Alias git stash poop to pop?
  • Git: Equivalent of `--full-history` for `git bisect` and `git blame`
  • Configuring SSH for git
  • How can I keep a git mirror in sync (including deleting branches)?
  • New Git repository has no “master” branch
  • 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 master

    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.

    Git Baby is a git and github fan, let's start git clone.