32

Can someone explain why this isn't working?

➜  workspace git:(REL-BRANCH-1.0.1d) ✗ git branch -a
  REL-BRANCH-1.0.1c
* REL-BRANCH-1.0.1d
  remotes/origin/REL-BRANCH-1.0.1c
  remotes/origin/master
➜  workspace git:(REL-BRANCH-1.0.1d) ✗ git checkout -t origin/master 
fatal: Cannot setup tracking information; starting point 'origin/master' is not a branch.
➜  workspace git:(REL-BRANCH-1.0.1d) ✗ git checkout -t remotes/origin/master
fatal: Cannot setup tracking information; starting point 'remotes/origin/master' is not a branch.
user2684301
  • 2,550
  • 1
  • 24
  • 33
  • 2
    Try `git remote update`, and check again. – xdazz Mar 17 '14 at 04:03
  • 1
    That's ... odd, to say the least. What *is* origin/master? What does `git branch -a -v -v` show, and what does `git rev-parse --symbolic-full-name origin/master` produce? It sure looks like an ordinary remote-branch... – torek Mar 17 '14 at 06:20
  • Thanks for the tips. I got frustrated and completely blew away the repo and started over and the issue is resolved. If I can close this question out, I will. – user2684301 Mar 17 '14 at 17:30

3 Answers3

62

Probably your origin remote is set up to fetch only certain branches. A simple

git remote set-branches --add origin master

will fix it.

ansiwen
  • 1,061
  • 8
  • 13
10

It is possible that your repo contains config that asks fetch command to retrieve only some specific branch(es) instead of just all of them. You can check the configuration you have using

git config --local --get-all remote.origin.fetch

It can return lines like +refs/heads/*:refs/remotes/origin/*, +refs/heads/master:refs/remotes/origin/master or +refs/heads/AnyOtherBranch:refs/remotes/origin/AnyOtherBranch. The first config string means that it fetches all the branches. The second and third are examples of fetch config only for specific branches. If you don't have config line with asterisk then you can use either

# Reset "remote.origin.fetch" to deal with all branches
git remote set-branches origin '*'

or

# Append new config line for specific branch
git remote set-branches --add origin AnyOtherBranch
Victor Yarema
  • 1,183
  • 13
  • 15
6

For anybody getting here via google while having the same problem (by 'the same' I mean the same error message not the same cause) with 'git svn' rather than just 'git':

Removing the -t option might help as explained in: git-svn: Cannot setup tracking information; starting point is not a branch

tomorrow
  • 1,260
  • 1
  • 14
  • 26