Karl
Karl

Reputation: 15014

Git denies the existence of remote branches

I have a git repo checked out from github, but it refuses to acknowledge any remote branches.

Here's what I've tried (names changed to protect the guilty):

$ git pull
Already up-to-date.
$ git fetch
$ git remote update
Fetching origin
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
$ git remote show
origin
$ git remote show origin
* remote origin
  Fetch URL: [email protected]:Someplace/someproject.git
  Push  URL: [email protected]:Someplace/someproject.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)
$ git remote -v
origin  [email protected]:Someplace/someproject.git (fetch)
origin  [email protected]:Someplace/someproject.git (push)

On another machine, it just works:

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/somebranch
  ...

Upvotes: 2

Views: 113

Answers (1)

VonC
VonC

Reputation: 1329082

First, you can confirm the existence of remote branches with git ls-remote

cd /patH/to/my/repo
git ls-remote

Or, from any directory:

git ls-remote [email protected]:Someplace/someproject.git

Second, make sure your local repo is set to fetch all branches with the right refspec:

git config remote.origin.fetch refs/heads/*:refs/remotes/origin/*

(as suggested by kan)

am I going to have to manually edit the config file every time I fetch a new repo?

No because refs/heads/*:refs/remotes/origin/* is the default refspec used by any git clone.
Unless, as torek mentions, you use git clone --single-branch, which is possible since Git 1.7.10.

Upvotes: 1

Related Questions