Git - 致命:远程源已经存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25420452/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:20:59  来源:igfitidea点击:

Git - fatal: remote origin already exists

gitgithubgithub-for-windows

提问by Brad Thrumble

I can not create origin remotely with remotecommand:

我无法使用remote命令远程创建原点:

$ git remote add origin https://github.com/LongKnight/git-basics.git
fatal: remote origin already exists.

To solve the error, I have tried this:

为了解决这个错误,我试过这个:

$ git remote -v origin
$ git remote -v show origin

It is not uploading the files from my local repository to the remote:

它不会将文件从我的本地存储库上传到远程:

$ git push -u origin master
fatal: 'origin' 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.

Does each repository have its own origin?

每个存储库都有自己的来源吗?



Solution:I was using the Powershell that came with Github or Git Shell as it is also called to do my tutorial, once I switched to Git Bash it worked fine.

解决方案:我使用的是 Github 或 Git Shell 附带的 Powershell,因为它也被称为我的教程,一旦我切换到 Git Bash,它就可以正常工作。

回答by VonC

A bit easier:

稍微简单一点:

git remote set-url origin https://github.com/LongKnight/git-basics.git

That will replace the current origin with a new one.

这将用新的原点替换当前的原点。

回答by Mayur Nagekar

Hmm.

唔。

It's quite strange as to why your origin doesn't have a value. Typically, it should look like this:

为什么您的来源没有价值,这很奇怪。通常,它应该如下所示:

[mayur.n@harry_potter]$ git remote -v
origin  /mnt/temp.git (fetch)
origin  /mnt/temp.git (push)

Your origin doesn't have the url associate with it. It's actually name value pair. So when you say "git push origin master", Git substitues the value of origin. In my case, it would be "/mnt/temp.git".

您的来源没有与之关联的网址。它实际上是名称值对。所以当你说“git push origin master”的时候,Git 代替了 origin 的值。在我的情况下,它将是“/mnt/temp.git”。

Now what can you do ?

现在你能做什么?

Try this:

尝试这个:

1) Clone the repository in another directory.

1) 将存储库克隆到另一个目录中。

2) run "git remote -v" and get the value of origin

2) 运行 " git remote -v" 并获取 origin 的值

3) In your case it looks like the value is "https://github.com/LongKnight/git-basics.git"

3)在您的情况下,该值看起来像“ https://github.com/LongKnight/git-basics.git

4) So come back to your working directory, and run "git remote add origin2 https://github.com/LongKnight/git-basics.git"

4) 所以回到你的工作目录,并运行“ git remote add origin2 https://github.com/LongKnight/git-basics.git

5) Run "git remote remove origin"

5)运行“ git remote remove origin

6) Now run "git remote rename origin2 origin"

6)现在运行“ git remote rename origin2 origin

7) Check what's the value of origin now with "git remote -v"

7) 现在用“git remote -v”检查 origin 的值是多少

8) It should be correctly set now. If so, run "git push"

8) 现在应该正确设置。如果是这样,请运行“ git push

回答by Aadi Manchekar

try this

尝试这个

git remote rm origin

git远程rm原点

then,

然后,

git remote add origin https://yourLink

git remote add origin https://yourLink