且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

GitHub“致命:远程源已经存在"

更新时间:2023-09-28 23:14:58

TL;DR 你应该只更新现有的遥控器:

TL;DR you should just update the existing remote:

$ git remote set-url origin git@github.com:ppreyer/first_app.git

长版:

如错误消息所示,已经有一个配置了相同名称的遥控器.因此,您可以添加具有不同名称的新遥控器,也可以在不需要时更新现有遥控器:

As the error message indicates, there is already a remote configured with the same name. So you can either add the new remote with a different name or update the existing one if you don't need it:

要添加一个新的遥控器,例如名为 github 而不是 origin(它显然已经存在于您的系统中),请执行以下操作:

To add a new remote, called for example github instead of origin (which obviously already exists in your system), do the following:

$ git remote add github git@github.com:ppreyer/first_app.git

但是请记住,在教程中的任何地方您都可以看到 origin",您应该将其替换为 github".例如 $ git push origin master 现在应该是 $ git push github master.

Remember though, everywhere in the tutorial you see "origin" you should replace it with "github". For example $ git push origin master should now be $ git push github master.

但是,如果您想查看已经存在的 origin 是什么,您可以执行 $ git remote -v.如果您认为这是由于某些错误,您可以像这样更新它:

However, if you want to see what that origin which already exists is, you can do a $ git remote -v. If you think this is there by some error, you can update it like so:

$ git remote set-url origin git@github.com:ppreyer/first_app.git