Git 错误:“上游”似乎不是 git 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32912359/
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
Git Error : 'upstream' does not appear to be a git repository
提问by kallada
I'm very new to Git, so facing some issues with it correct usage. Here is my scenario.
我对 Git 很陌生,所以在正确使用它时遇到了一些问题。这是我的场景。
I have a fork of my master repository and cloned it into my local. In that, I have 2 branches for different fixes.
我有一个我的主存储库的分支并将它克隆到我的本地。在那,我有 2 个分支用于不同的修复。
When I commit, I saw a statement in the git-we saying that I'm 3 commits ahead and around 20 commits behind.
当我提交时,我在 git-we 中看到一个声明,说我提前了 3 个提交,落后了大约 20 个提交。
I understand that my fork is not in sync with master. Also I need to merge the two branches too (or should i do it?)
我知道我的 fork 与 master 不同步。我也需要合并这两个分支(或者我应该这样做吗?)
I used the windows client to syncing. But seems I'm not following the Git way. So, I tried to follow the steps described in https://help.github.com/articles/syncing-a-fork/which is giving me an error as follows (I'm using windows).
我使用 Windows 客户端进行同步。但似乎我没有遵循 Git 的方式。因此,我尝试按照https://help.github.com/articles/syncing-a-fork/中描述的步骤操作,这给了我如下错误(我使用的是 Windows)。
$>git fetch upstream
fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I'm a bit confused. Please help me with steps I should follow in this scenario.
我有点困惑。请帮助我在这种情况下应该遵循的步骤。
@HuStmpHrrr
@HuStmpHrrr
Sorry for adding the details in comments I'll modify the question for readability
抱歉在评论中添加详细信息我会修改问题以提高可读性
By executing the command:
通过执行命令:
$>git remote returning two values
acme-development (which the name of my actual/main repository, from where I forked) and
origin
Adding some more info.
添加更多信息。
After making a fetch, I tried a origin/master merge on to my master
Please see the screenshot
获取后,我尝试将 origin/master 合并到我的 master 请看截图
But, if I login to my Github online account, it is saying a different story.
但是,如果我登录到我的 Github 在线帐户,它会说一个不同的故事。
My git client says that the local repo is up to date. But the online git says that we are 42 commits behind and 7 commits ahead.
我的 git 客户端说本地仓库是最新的。但是在线 git 说我们落后 42 次提交,提前 7 次提交。
回答by Rattle
The article you link to (though it may have changed since you asked) starts with a reference to https://help.github.com/articles/configuring-a-remote-for-a-fork/. If you complete this you will have a new remote repository named upstream pointing to the original repository which you forked, and git fetch upstream
will work.
您链接到的文章(尽管自您询问以来它可能已更改)以对https://help.github.com/articles/configuring-a-remote-for-a-fork/的引用开头。如果您完成此操作,您将拥有一个名为 upstream 的新远程存储库,指向您分叉的原始存储库,并且git fetch upstream
可以正常工作。
回答by Makoto
So there's a few things to clarify:
所以有几点需要澄清:
Upstreamis the conceptual name of the remote repository (or repositories) that exist. Most projects only have one upstream repository.
The nameof the upstream repository can vary from project to project, but by convention is origin.
上游是存在的远程存储库(或多个存储库)的概念名称。大多数项目只有一个上游存储库。
上游存储库的名称可能因项目而异,但按照惯例是origin。
That said, I'm willing to bet that you got the name of your upstream repo and the upstream repo concept confused, and you should be executing git fetch origin
. Verify with git remote
; use the appropriate name from that list.
也就是说,我敢打赌,您对上游存储库的名称和上游存储库概念混淆了,您应该执行git fetch origin
. 验证与git remote
; 使用该列表中的适当名称。
However, if you only have one upstream repo, performing git fetch
will accomplish the same thing.
但是,如果您只有一个上游存储库,执行git fetch
将完成相同的事情。