git 分支不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16503034/
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
Branch does not exist
提问by Chris
the command
命令
git branch --set-upstream-to develop origin/develop
results in the error
导致错误
fatal: branch 'origin/develop' does not exist
I am not sure what this means other than origin develop does not exist. Does that mean it doesn't exist on the server or on my local machine?
我不确定这意味着什么,除了起源发展不存在。这是否意味着它不存在于服务器或我的本地机器上?
I am a git newbie but I am in the process of setting up my site to handle deployments with git as a means to learn git.
我是 git 新手,但我正在设置我的站点以使用 git 作为学习 git 的一种方式来处理部署。
回答by Gary Fixler
originis the name of a remote, which is just another repo that your repo knows about. You name repos when adding them, ala git remote add somename other/repo/path, and then you can fetchand pullfrom them, and if they're bare repos, pushto them. When you clone a repo, git sets up a remote for you pointing to the one you cloned from, and names it originby default. origin/developrefers to the developbranch in the originremote repo.
origin是远程的名称,它只是您的存储库知道的另一个存储库。当添加他们你的名字回购,鼻翼git remote add somename other/repo/path,然后你可以fetch和pull来自他们,如果他们是裸露的回购协议,push给他们。当您克隆一个 repo 时,git 会为您设置一个指向您从中克隆的远程仓库,并origin在默认情况下为其命名。origin/develop指远程仓库中的develop分支origin。
If you've made a branch locally, you can push it to a particular remote to create it there, and until you've created it there, you can't set it as upstream. In your case, you would do git push origin develop. Then you could set it as upstream, but you can squeeze that operation into the push operation with -u, so git push -u origin develop, which both pushes your branch to origin, and sets up your local branch to track it. Note that push -uwas added in git 1.7.0.
如果你在本地创建了一个分支,你可以将它推送到一个特定的远程来在那里创建它,并且在你在那里创建它之前,你不能将它设置为上游。在你的情况下,你会做git push origin develop. 然后您可以将其设置为上游,但您可以将该操作压缩到推送操作中-u,所以git push -u origin develop,这既可以将您的分支推送到origin,也可以设置您的本地分支来跟踪它。请注意,这push -u是在 git 1.7.0 中添加的。
回答by erkanyildiz
First make sure you are at developbranch.
Then just use git branch --set-upstream-to origin/develop
首先确保你在develop分行。然后只需使用git branch --set-upstream-to origin/develop
回答by Song WANG
Git defines git branch --set-upstream-to <upstream> [<branchname>].
Git 定义了git branch --set-upstream-to <upstream> [<branchname>].
Here <upstream>specifies the remote branch and [<branchname>]is the local branch name and if you no branch is specified, it defaults to the current branch.
这里<upstream>指定远程分支,[<branchname>]是本地分支名称,如果没有指定分支,则默认为当前分支。
So, it should be git branch --set-upstream-to origin/develop develop
所以,应该是 git branch --set-upstream-to origin/develop develop
-uis interchangeable with --set-upstream-to
-u可与 --set-upstream-to

