GIT不是';我不去拿我的新树枝

GIT不是';我不去拿我的新树枝,git,git-remote,git-fetch,Git,Git Remote,Git Fetch,我已在我的遥控器上创建了一个新分支,因此我希望这样做: $ git fetch && git checkout feature/name 但是,我得到了这个错误: error: pathspec 'feature/name' did not match any file(s) known to git. 当我自己运行git-fetch时,它不会返回任何东西,我还尝试了git-fetch-origin,但也不起作用 git remote只返回一个名为origin的远程设备 我的

我已在我的遥控器上创建了一个新分支,因此我希望这样做:

$ git fetch && git checkout feature/name
但是,我得到了这个错误:

error: pathspec 'feature/name' did not match any file(s) known to git.
当我自己运行
git-fetch
时,它不会返回任何东西,我还尝试了
git-fetch-origin
,但也不起作用

git remote
只返回一个名为
origin
的远程设备

我的配置如下所示:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = removed as it is a private repo
    fetch = +refs/heads/staging:refs/remotes/origin/staging
[branch "staging"]
    remote = origin
    merge = refs/heads/staging

如果您使用的是GIt>1.9.X,则默认上游值为
simple

如果您想获得所有的分支和标记,您应该使用:
git fetch--all--prune

--all
将获取所有分支和标记
--prune
将删除所有已删除的分支和标记


这些标志将应用于您的本地存储库。

根据Andrew C的评论。我将git配置中的
fetch
行更改为:

fetch=+refs/heads/*:refs/remotes/origin/*

修复方法是更正您的
remote.origin.fetch
参数,例如

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

所以所有的分支都可以被提取。请参阅:

您可以使用
git pull
,但我的分支还不存在。我还没有在本地repo中创建分支,也可能没有远程分支的原始分支。您的origin.fetch行不是git默认行。正常是
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
@AndrewC:这就是问题的原因;您应该将其添加为答案。@torek-这需要更多的工作:)而这一个闻起来像是重复的。