如何解决Git错误“所请求的上游分支'上游/主站'不存在"; [英] how to address Git error "the requested upstream branch 'upstream/master' does not exist"

查看:886
本文介绍了如何解决Git错误“所请求的上游分支'上游/主站'不存在";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照一些步骤为GitHub上的存储库做贡献,但其中一个步骤不起作用.步骤在这里: https: //github.com/wdbm/qTox/blob/master/CONTRIBUTING.md#how-to-open-a-pull-request .

I am attempting to follow some steps to contribute to a repository on GitHub and one of the steps is not working. The steps are here: https://github.com/wdbm/qTox/blob/master/CONTRIBUTING.md#how-to-open-a-pull-request.

我在GitHub上存储库.

I fork the repository on GitHub.

我克隆存储库:

git clone https://github.com/<YOUR_USER>/qTox.git

我访问本地存储库的目录

I access the directory of the local repository:

cd qTox

我添加了上游远程服务器,以便能够从上游存储库中获取

I add the upstream remote in order to be able to fetch from the upstream repository:

git remote add upstream https://github.com/qTox/qTox.git

我尝试将本地master分支指向上游存储库:

I attempt to point the local master branch to the upstream repository:

git branch master --set-upstream-to=upstream/master

此命令失败,并显示以下错误消息:

This command fails with the following error message:

error: the requested upstream branch 'upstream/master' does not exist
hint: 
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint: 
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.

我应如何解决此错误?我正在使用Git 2.9.3.

How should I address this error? I am using Git 2.9.3.

推荐答案

git fetch upstream master:master:仅当您不在时 c1> . 如果您使用的是master,那么简单的git fetch upstream就足够了.

git fetch upstream master:master: this work only when you are not on master. If you are on master, a simple git fetch upstream is enough.

然后,您可以将本地master链接到远程跟踪分支upstream/master(刚刚已获取)

Then you can link your local master to the remote tracking branch upstream/master (which has just been fetched)

git branch -u upstream/master master

然后您可以使用git pull更新master.
同样,如果您不在master上,那么可以,git fetch upstream master:master将起作用.

Then you can use git pull to update master.
Again, if you are not on master, then yes, git fetch upstream master:master will work.

Luh_ 在refspec中也提到了错字问题:请参阅"

Luh_ mentions also a typo issue in the refspec: see "git fetch doesn't fetch all branches".

这篇关于如何解决Git错误“所请求的上游分支'上游/主站'不存在";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆