我在GitHub的某个位置有我的项目,[email protected]:myname/oldrep.git
。'git push'已经存在于一个新的版本库中的远程原点
现在我想将我的所有代码推送到其他位置的新存储库[email protected]:newname/newrep.git
。
我使用的命令:
git的远程添加原点[email protected]:MYNAME/oldrep.git
但我接收到该:
致命:远程原点已经存在。
我在GitHub的某个位置有我的项目,[email protected]:myname/oldrep.git
。'git push'已经存在于一个新的版本库中的远程原点
现在我想将我的所有代码推送到其他位置的新存储库[email protected]:newname/newrep.git
。
我使用的命令:
git的远程添加原点[email protected]:MYNAME/oldrep.git
但我接收到该:
致命:远程原点已经存在。
您正在收到此错误,因为“原点”不可用。 “起源”是一个不属于命令的约定。 “origin”是远程存储库的本地名称。
例如,你也可以这样写:
git remote add myorigin [email protected]:myname/oldrep.git
git remote add testtest [email protected]:myname/oldrep.git
参见手册:
http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
要删除您输入远程仓库:
git remote rm origin
再次 “原点”是远程存储库的名称,如果你想要 删除“上游”远程:
git remote rm upstream
你也可以改变你要推到在REPOHOME/git的/ config文件
(其中REPOHOME是你的本地克隆路径仓库名的存储库)。
您可以在文本编辑器中简单编辑配置文件。
在~/.gitconfig
你需要把东西像如下:
[user]
name = Uzumaki Naruto
email = [email protected]
[github]
user = myname
token = ff44ff8da195fee471eed6543b53f1ff
在oldrep/.git/config
文件(版本库的配置文件中):
[remote "github"]
url = [email protected]:myname/oldrep.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
如果有存储库配置文件中的远程部分以及URL匹配,您只需添加推送配置即可。如果您使用公共URL进行抓取,您可以将URL作为'pushurl'(警告:这需要刚刚发布的Git 1.6.4版)。
如果错误命名的本地名称为“原产地”,你可以用下面的删除:
git remote rm origin
您不必删除现有的“原产地”遥控器,只需使用一个名称除了远程添加的“来源”以外,例如
git的远程添加github上 [email protected]:MYNAME/oldrep.git
以前的解决方案似乎忽略原点,他们只建议使用其他名称。当您只想使用git push origin
时,请继续阅读。
问题出现是因为Git配置的顺序错误。您可能已经在您的.git配置中添加了“git origin”。
你可以用下面的行改变你的Git配置中的远程产地:
git remote set-url origin [email protected]:username/projectname.git
这条命令设置一个新的URL为要推到Git仓库。 重要的是要填你自己的用户名和项目名称
我得到了同样的问题,这里是做一些研究后,我如何固定它:
Git Shell
。这将打开包含Git命令的电源外壳。类型git remote -v
的cd C:\path\to\old\repository
显示状态以获取读取和远程推远程路径。如果你的本地库连接到远程,它会显示这样的事情:
起源https://[email protected]/team-or-user-name/myproject.git(取) 起源https://[email protected]/team-or-user-name/myproject.git(推)
如果没有连接,它可能只显示origin
。
现在再次使用
git remote rm origin
检查步骤4.从本地资源库远程仓库它应该显示origin
只,而不是获取和推动路径。
现在您的旧远程存储库已断开连接,您可以添加新的远程存储库。使用以下连接到您的新存储库。
注意:如果您使用的是Bitbucket,您将首先在Bitbucket上创建一个项目。创建之后,Bitbucket将显示所有必需的Git命令,以将您的存储库推送到远程,这看起来与下一个代码片段类似。但是,这也适用于其他存储库。
cd /path/to/my/repo # If haven't done yet
git remote add mynewrepo https://[email protected]/team-or-user-name/myproject.git
git push -u mynewrepo master # To push changes for the first time
就是这样。
当我第一次使用Bitbucket设置时,我遇到了同样的问题。
我的问题是,我需要改变自定义的东西的单词来源。我使用了应用程序的名称。因此:
git remote add AppName https://[email protected]/somewhere/something.git
您应该将远程存储库的名称更改为其他名称。
git remote add origin [email protected]:myname/oldrep.git
到
git remote add neworigin [email protected]:myname/oldrep.git
我认为这应该工作。
是的,这些是用于存储库初始化和添加一个新的远程。只是改名而已。
git remote rm origin
git remote add origin [email protected]:username/myapp.git
当您忘记进行第一次提交时也会发生这种情况。
METHOD1->
由于产地存在将其删除。
git remote rm origin
git remote add origin https://github.com/USERNAME/REPOSITORY.git
METHOD2->
人们也可以通过改变现有的远程存储库URL - >远程Git设置网址
如果要更新使用HTTPS
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
如果您要更新为使用SSH
git remote set-url origin [email protected]:USERNAME/REPOSITORY.git
如果尝试更新不存在的远程,您将收到错误消息。所以要小心。
METHOD3->
使用GIT中远程重命名的命令到现有的远程重命名。 现有的远程名称,例如,起源。
git remote rename origin startpoint
# Change remote name from 'origin' to 'startpoint'
要验证远程的新名称 - >
git remote -v
如果新的Git试试这个教程 - >
发出命令,$输出>远程Git -v显示 – sykora 2009-08-03 11:50:17
[Github“fatal:remote origin already exists”]的可能重复](http://stackoverflow.com/questions/10904339/github-fatal-remo te-origin-already-exists) – 2014-02-05 14:52:16
如果您知道旧版本库的URL,一个好方法是在新创建的版本库底部使用**“从另一个版本库导入”**。 – 2016-07-16 04:58:53