git 无法跟踪远程分支 - 无法识别来源/开发
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17210624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't track remote branch - doesn't recognize origin/develop
提问by Shai Reznik - HiRez.io
I have git 1.8.3 and a repo with 'master' and 'develop' branches.
我有 git 1.8.3 和一个带有“master”和“develop”分支的仓库。
From my local 'develop' branch, I'm trying to do the following command -
从我本地的“开发”分支,我正在尝试执行以下命令 -
git branch -u origin/develop
git branch -u origin/develop
and I get an error of
我得到一个错误
error: the requested upstream branch 'origin/develop' does not exist
error: the requested upstream branch 'origin/develop' does not exist
When I check git branch -r
I see only origin/master
当我检查时,git branch -r
我只看到origin/master
I'm trying to find a way to make my system recognize that there is also a origin/develop
and can't find any solution that works.
我试图找到一种方法让我的系统认识到还有一个origin/develop
并且找不到任何有效的解决方案。
回答by Jan Krüger
- If the branch
develop
already exists in the remote repository, usegit fetch
to update your "remote-tracking branches" (local mirrors).- This requires that the fetch refspec is set correctly (in
.git/config
in the section for your remote); the default isfetch = +refs/heads/*:refs/remotes/<name of remote>/*
. In some cases, configuration may be set up to fetch only one branch (specific branch name used instead of wildcard). It should be safe to change the configuration; this will allow fetching all branches.
- This requires that the fetch refspec is set correctly (in
- If the branch doesn't exist yet in the remote repository, you can set up the association while pushing it for the first time:
git push -u origin develop
(that takes care of what you're trying to do with your command at the same time as it pushes the branch)
- 如果该分支
develop
已存在于远程存储库中,请用于git fetch
更新您的“远程跟踪分支”(本地镜像)。- 这需要正确设置 fetch refspec(在
.git/config
远程部分中);默认为fetch = +refs/heads/*:refs/remotes/<name of remote>/*
. 在某些情况下,配置可能会设置为仅获取一个分支(使用特定的分支名称而不是通配符)。更改配置应该是安全的;这将允许获取所有分支。
- 这需要正确设置 fetch refspec(在
- 如果远程存储库中尚不存在该分支,您可以在第一次推送它时设置关联:(
git push -u origin develop
这会在推送命令的同时处理您尝试对命令执行的操作分支)