[英]Git - fatal: remote origin already exists
我无法使用remote
命令远程创建原点:
$ git remote add origin https://github.com/LongKnight/git-basics.git
fatal: remote origin already exists.
为了解决这个错误,我试过这个:
$ git remote -v origin
$ git remote -v show origin
它不会将文件从我的本地存储库上传到远程:
$ 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.
每个存储库都有自己的来源吗?
解决方案:我使用的是 Github 或 Git Shell 附带的 Powershell,因为它也被称为做我的教程,一旦我切换到 Git Bash,它就可以正常工作。
简单一点:
git remote set-url origin https://github.com/LongKnight/git-basics.git
这将用新的原点替换当前原点。
尝试这个
git 远程 rm 起源
然后,
git remote add origin https://yourLink
我遇到了类似的问题,但我使用以下方法解决了它:
git remote set-url origin https://GitHub.com/Fasunle/my_portfolio.git
接着,
git push main master
它奏效了。
为了使用 git push,你必须在 local_branch 后面指定最终目的地(在我自己的例子中,它是本地分支的 master 和远程分支的 main)。 然而,它们可能是相同的。 如:
git push -u main local_branch_to_push
或者
git push -u master local_branch_to_push
唔。
为什么你的起源没有价值,这很奇怪。 通常,它应该如下所示:
[mayur.n@harry_potter]$ git remote -v
origin /mnt/temp.git (fetch)
origin /mnt/temp.git (push)
您的来源没有与之关联的 url。 它实际上是名称值对。 所以当你说“git push origin master”时,Git 会替换 origin 的值。 就我而言,它将是“/mnt/temp.git”。
现在你能做什么?
尝试这个:
1)将存储库克隆到另一个目录中。
2) 运行“ git remote -v
”并获取origin的值
3)在您的情况下,该值看起来是“ https://github.com/LongKnight/git-basics.git ”
4)所以回到你的工作目录,然后运行“ git remote add origin2 https://github.com/LongKnight/git-basics.git
”
5) 运行“ git remote remove origin
”
6) 现在运行“ git remote rename origin2 origin
”
7) 现在用“git remote -v”检查 origin 的值是多少
8) 现在应该正确设置。 如果是这样,运行“ git push
”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.