远程源已经存在于“git push”上 到一个新的存储库
我的项目位于 GitHub 上的某个位置,[电子邮件受保护]:myname/oldrep.git
。
现在我想将所有代码推送到其他位置的新存储库, [电子邮件受保护]:newname/newrep.git
。
我使用了命令:
git remote add origin [email protected]:myname/oldrep.git
但我收到了这个:
致命:远程源已存在。
I have my project on GitHub at some location, [email protected]:myname/oldrep.git
.
Now I want to push all my code to a new repository at some other location, [email protected]:newname/newrep.git
.
I used the command:
git remote add origin [email protected]:myname/oldrep.git
but I am receiving this:
fatal: remote origin already exists.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(22)
您收到此错误是因为“原点”不可用。 “origin”是一个约定,不是命令的一部分。 “origin”是远程存储库的本地名称。
例如,您也可以编写:
请参阅手册:
http: //www.kernel.org/pub/software/scm/git/docs/git-remote.html
要删除远程存储库,请输入:
同样,“origin”是远程存储库的名称(如果您想要)
删除“上游”遥控器:
You are getting this error because "origin" is not available. "origin" is a convention not part of the command. "origin" is the local name of the remote repository.
For example you could also write:
See the manual:
http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
To remove a remote repository you enter:
Again "origin" is the name of the remote repository if you want to
remove the "upstream" remote:
以前的解决方案似乎忽略了起源,他们只建议使用另一个名称。 当您只想使用 git Push origin 时,请继续阅读。
出现此问题的原因是 Git 配置顺序错误。 您可能已经将“git origin”添加到您的 .git 配置中。
您可以使用以下行更改 Git 配置中的远程源:
此命令为要推送到的 Git 存储库设置新的 URL。
重要的是填写您自己的用户名和项目名称
The previous solutions seem to ignore origin, and they only suggest to use another name. When you just want to use
git push origin
, keep reading.The problem appears because a wrong order of Git configuration is followed. You might have already added a 'git origin' to your .git configuration.
You can change the remote origin in your Git configuration with the following line:
This command sets a new URL for the Git repository you want to push to.
Important is to fill in your own username and projectname
如果您错误地将本地名称命名为“origin”,您可以使用以下命令将其删除:
If you have mistakenly named the local name as "origin", you may remove it with the following:
方法1->
由于原点已存在,请将其删除。
方法2->
还可以通过 ->git remote set-url 更改现有远程存储库 URL
如果您要更新为使用 HTTPS
如果您要更新为使用 SSH
如果尝试更新远程不存在,您将收到错误。 所以要小心。
方法3->
使用 git remote rename 命令重命名现有远程。
现有的远程名称,例如 origin。
验证遥控器的新名称->
如果是 Git 新手,请尝试本教程 ->
尝试一下GIT 教程
METHOD1->
Since origin already exist remove it.
METHOD2->
One can also change existing remote repository URL by ->git remote set-url
If you're updating to use HTTPS
If you're updating to use SSH
If trying to update a remote that doesn't exist you will receive a error. So be careful of that.
METHOD3->
Use the git remote rename command to rename an existing remote.
An existing remote name, for example, origin.
To verify remote's new name->
If new to Git try this tutorial->
TRY GIT TUTORIAL
您只需在文本编辑器中编辑配置文件即可。
在
~/.gitconfig
中,您需要放入类似以下内容:在
oldrep/.git/config
文件中(在配置中)文件):如果您的存储库配置文件中有远程部分,并且 URL 匹配,则只需添加推送配置。 如果您使用公共 URL 进行获取,则可以将用于推送的 URL 输入为“pushurl”(警告:这需要刚刚发布的 Git 版本 1.6.4)。
You can simply edit your configuration file in a text editor.
In the
~/.gitconfig
you need to put in something like the following:In the
oldrep/.git/config
file (in the configuration file of your repository):If there is a remote section in your repository's configuration file, and the URL matches, you need only to add push configuration. If you use a public URL for fetching, you can put in the URL for pushing as 'pushurl' (warning: this requires the just-released Git version 1.6.4).
我遇到了同样的问题,经过一些研究后,我解决了这个问题:
Git Shell
。 这将打开一个包含 Git 命令的电源 shell。输入
git remote -v
以获取远程获取和推送的远程路径。 如果您的本地存储库连接到远程存储库,它将显示如下内容:如果未连接,则可能仅显示
origin
。现在使用以下命令从本地存储库中删除远程存储库
origin
,而不是获取和推送路径。现在您的旧远程存储库已断开连接,您可以添加新的远程存储库。 使用以下命令连接到您的新存储库:
注意:如果您使用 Bitbucket,您将首先在 Bitbucket 上创建一个项目。 创建后,Bitbucket 将显示将存储库推送到远程所需的所有 Git 命令,这与下一个代码片段类似。 不过,这也适用于其他存储库。
就是这样。
I had the same issue, and here is how I fixed it, after doing some research:
Git Shell
from the task menu. This will open a power shell including Git commands.cd C:\path\to\old\repository
.Type
git remote -v
to get the remote path for fetch and push remote. If your local repository is connected to a remote, it will show something like this:If it's not connected, it might show
origin
only.Now remove the remote repository from the local repository by using
Check again with
git remote -v
, as in step 4. It should showorigin
only, instead of the fetch and push path.Now that your old remote repository is disconnected, you can add the new remote repository. Use the following to connect to your new repository:
Note: In case you are using Bitbucket, you would create a project on Bitbucket first. After creation, Bitbucket will display all required Git commands to push your repository to remote, which look similar to the next code snippet. However, this works for other repositories as well.
That's it.
git 远程 rm 原点
git 远程 -v
它不会显示任何存储库名称
git Remote add origin [email protected ]:用户名/myapp.git
git Push origin master
它将启动该过程并创建新分支。
您可以看到您的工作已推送到github。
git remote rm origin
git remote -v
It will not display any repository name
git remote add origin [email protected]:username/myapp.git
git push origin master
It will start the process and creating the new branch.
You can see your work is pushed to github.
下面的两个命令应该有助于设置。
The below two commands should help set up.
您不必删除现有的“origin”远程,只需使用“origin”以外的名称进行远程添加,例如
git remote add github [电子邮件受保护]:myname/oldrep.git
You don't have to remove your existing "origin" remote, just use a name other than "origin" for your remote add, e.g.
git remote add github [email protected]:myname/oldrep.git
当我第一次使用 Bitbucket 设置时,我遇到了同样的问题。
我的问题是我需要将单词 origin 更改为自定义的内容。 我使用了应用程序的名称。 所以:
I had the same problem when I first set up using Bitbucket.
My problem was that I needed to change the word origin for something self-defined. I used the name of the application. So:
您应该将远程存储库的名称更改为其他名称。
我认为
这应该有效。
是的,这些用于存储库初始化和添加新的远程。 只是换了个名字而已。
You should change the name of the remote repository to something else.
to
I think this should work.
Yes, these are for repository init and adding a new remote. Just with a change of name.
您还可以在 REPOHOME/.git/config 文件中更改要推送到的存储库名称
(其中 REPOHOME 是存储库本地克隆的路径)。
You could also change the repository name you wish to push to in the REPOHOME/.git/config file
(where REPOHOME is the path to your local clone of the repository).
您需要检查
来源
,如果不存在则添加。创建文件
check.sh
,粘贴脚本更新您的 git 存储库 URL 并运行./check.sh
。You need to check the
origin
and add if not exists.Create file
check.sh
, paste the script update your git repository URL and run./check.sh
.我有同样的问题,但我找到了解决方案。 基本上,“起源”是克隆项目的另一个名称。 现在错误
实际上意味着原点已经存在。 因此,要解决这个问题,我们的目标应该是消除它。
为此目的:
现在再次添加它
这确实解决了我的问题。
I had the same issue but I found the solution to it. Basically "origin" is another name from where your project was cloned. Now the error
LITERALLY means origin already exists. And hence to solve this issue, our goal should be to remove it.
For this purpose:
Now add it again
This did fix my issue.
当您忘记进行第一次提交时,也可能会发生这种情况。
This can also happen when you forget to make a first commit.
我自己刚刚遇到这个问题,我只是通过删除原点来删除它。
origin,则此命令会删除
origin
,请尝试执行此命令。如果您已将远程存储库添加为
I just faced this issue myself and I just removed it by removing the origin.
the
origin
is removed by this commandif you've added the remote repo as
origin
try implementing this command.尝试删除第一个现有的源,为了查看哪个现有源已在 bash 中注册,您可以触发以下命令。
在您知道哪个版本的 origin 已在 bash 中注册后,您可以通过触发以下命令来删除现有的 origin
一旦您删除了现有的 origin,您可以在您的情况下通过触发以下命令来添加新的 origin ..
一旦您在 git 中添加了您的 origin,那么您可以将本地提交推送到远程源
Try to remove first existing origin, In order to see the which existing origin has registered with bash you can fire below command.
after you know the which version of origin has register with bash then you can remove existing origin by firing below command
Once you removed existing origin you can add new origin by firing below command in you case ..
Once you add your origin in git, then you can push your local commit to remote origin
步骤:1
步骤:2
示例:
Step:1
Step:2
Example:
如果你想在 github 中创建一个具有相同项目的新存储库,并且之前的 Remote 不允许你这样做,在这种情况下,首先删除 github 上的该存储库,那么你只需删除 .git 文件夹C: \Users\Shiva\AndroidStudioProjects\yourprojectname\.git 删除该文件夹,(确保您单击隐藏文件,因为该文件夹是隐藏的)
同时单击 android studio 设置->版本控制中的减号(删除按钮)
单击此处从 android 中删除版本控制 然后您将能够创建新的存储库。
if you want to create a new repository with the same project inside the github and the previous Remote is not allowing you to do that in that case First Delete That Repository on github then you simply need to delete the .git folder C:\Users\Shiva\AndroidStudioProjects\yourprojectname\.git delete that folder,(make sure you click on hidden file because this folder is hidden )
Also click on the minus(Remove button) from the android studio Setting->VersionControl
click here for removing the Version control from android And then you will be able to create new Repository.
试试这个命令,它对我有用。
rm -rf .git/
Try this command it works for me.
rm -rf .git/
进而
and then