Git否认存在远程分支机构 [英] Git denies the existence of remote branches
问题描述
我有一个从github签出的git repo,但是它拒绝确认任何远程分支.
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: git@github.com:Someplace/someproject.git
Push URL: git@github.com: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 git@github.com:Someplace/someproject.git (fetch)
origin git@github.com: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
...
推荐答案
First, you can confirm the existence of remote branches with git ls-remote
cd /patH/to/my/repo
git ls-remote
或者,从任何目录:
git ls-remote git@github.com: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/*
(由 kan 建议)
我每次获取新存储库时都必须手动编辑配置文件吗?
am I going to have to manually edit the config file every time I fetch a new repo?
否,因为refs/heads/*:refs/remotes/origin/*
是任何git clone
使用的默认参考规范.
除非 torek 提到,否则您将使用git clone --single-branch
,即
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.
这篇关于Git否认存在远程分支机构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!