我有我的项目在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
但我所领受的是:
致命:远程源已经存在。
当前回答
我也有同样的问题,但我找到了解决方案。基本上,“origin”是项目克隆位置的另一个名称。现在是错误
fatal: remote origin already exists.
字面意思是原点已经存在。因此,要解决这个问题,我们的目标应该是消除它。 为此目的:
git remote rm origin
现在再添加一次
git remote add origin https://github.com/__enter your username here__/__your repositoryname.git__
这确实解决了我的问题。
其他回答
我自己也遇到过这个问题我只是通过移除原点来移除它。 该命令将删除原点
git remote rm origin
如果您已经将远程回购添加为源,请尝试执行此命令。
Git远程rm来源 Git remote -v 它不会显示任何存储库名称 Git远程添加源git@github.com:用户名/myapp.git Git push origin master 它将启动流程并创建新分支。 你可以看到你的作品被推送到github。
git remote rm origin
然后
git push -f
您可以简单地在文本编辑器中编辑配置文件。
在~/。你需要在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版本)。
如果您错误地将本地名称命名为“origin”,您可以使用以下方法删除它:
git remote rm origin