我有我的项目在GitHub上的一些位置,git@github.com:myname/oldrep.git。

现在,我想将所有代码推到其他位置的新存储库git@github.com:newname/newrep.git。

我使用命令:

git remote add origin git@github.com:myname/oldrep.git

但我所领受的是:

致命:远程源已经存在。


当前回答

您还可以在REPOHOME/中更改您希望推入的存储库名称。git /配置文件

(其中REPOHOME是存储库本地克隆的路径)。

其他回答

git remote rm origin 

然后

git push -f 

您得到这个错误是因为“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

试试这个命令,对我有用。

Rm -rf .git/

您还可以在REPOHOME/中更改您希望推入的存储库名称。git /配置文件

(其中REPOHOME是存储库本地克隆的路径)。

我也有同样的问题,但我找到了解决方案。基本上,“origin”是项目克隆位置的另一个名称。现在是错误

fatal: remote origin already exists.

字面意思是原点已经存在。因此,要解决这个问题,我们的目标应该是消除它。 为此目的:

git remote rm origin

现在再添加一次

git remote add origin https://github.com/__enter your username here__/__your repositoryname.git__

这确实解决了我的问题。