我有我的项目在GitHub上的一些位置,git@github.com:myname/oldrep.git。
现在,我想将所有代码推到其他位置的新存储库git@github.com:newname/newrep.git。
我使用命令:
git remote add origin git@github.com:myname/oldrep.git
但我所领受的是:
致命:远程源已经存在。
我有我的项目在GitHub上的一些位置,git@github.com:myname/oldrep.git。
现在,我想将所有代码推到其他位置的新存储库git@github.com:newname/newrep.git。
我使用命令:
git remote add origin git@github.com:myname/oldrep.git
但我所领受的是:
致命:远程源已经存在。
当前回答
METHOD1 - - - >
因为原点已经存在,删除它。
git remote rm origin
git remote add origin https://github.com/USERNAME/REPOSITORY.git
METHOD2 - - - >
还可以通过->git remote set-url更改现有的远程存储库URL
如果您正在更新使用HTTPS
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
如果您正在更新以使用SSH
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
如果试图更新一个不存在的远程,您将收到一个错误。所以要小心。
METHOD3 - - - >
使用git remote rename命令重命名已存在的远程。 一个现有的远程名称,例如origin。
git remote rename origin startpoint
# Change remote name from 'origin' to 'startpoint'
验证远程的新名称->
git remote -v
如果刚接触Git,试试这个教程->
试试git教程
其他回答
您还可以在REPOHOME/中更改您希望推入的存储库名称。git /配置文件
(其中REPOHOME是存储库本地克隆的路径)。
您得到这个错误是因为“origin”不可用。“origin”是一个约定,不是命令的一部分。“origin”是远程存储库的本地名称。
例如,你也可以这样写:
git remote add myorigin git@github.com:myname/oldrep.git
git remote add testtest git@github.com:myname/oldrep.git
详见说明书:
http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
要删除远程存储库,请输入:
git remote rm origin
同样,如果需要的话,“origin”是远程存储库的名称 移除“上游”遥控器:
git remote rm upstream
METHOD1 - - - >
因为原点已经存在,删除它。
git remote rm origin
git remote add origin https://github.com/USERNAME/REPOSITORY.git
METHOD2 - - - >
还可以通过->git remote set-url更改现有的远程存储库URL
如果您正在更新使用HTTPS
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
如果您正在更新以使用SSH
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
如果试图更新一个不存在的远程,您将收到一个错误。所以要小心。
METHOD3 - - - >
使用git remote rename命令重命名已存在的远程。 一个现有的远程名称,例如origin。
git remote rename origin startpoint
# Change remote name from 'origin' to 'startpoint'
验证远程的新名称->
git remote -v
如果刚接触Git,试试这个教程->
试试git教程
如果您错误地将本地名称命名为“origin”,您可以使用以下方法删除它:
git remote rm origin
您可以简单地在文本编辑器中编辑配置文件。
在~/。你需要在Gitconfig中输入如下内容:
[user]
name = Uzumaki Naruto
email = myname@example.com
[github]
user = myname
token = ff44ff8da195fee471eed6543b53f1ff
In the oldrep/。Git /配置文件(在存储库的配置文件中):
[remote "github"]
url = git@github.com:myname/oldrep.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
如果您的存储库的配置文件中有一个远程部分,并且URL匹配,您只需要添加推送配置。如果你使用一个公共URL进行抓取,你可以将用于推送的URL输入为“pushurl”(警告:这需要刚刚发布的Git 1.6.4版本)。