[英]Push local git to new remote
I have 2 git repositories set up, and I did a lot of coding in 1. Someone else grabbed the code to make changes to the code, but never pushed them up. 我设置了2个git存储库,并在1个代码中做了很多编码。其他人抓住了代码以对代码进行更改,但从未提出来。
The changes are now so large, I want to push it to an entirely new repository. 现在的更改是如此之大,我想将其推送到一个全新的存储库中。 I have their computer, and I tried to git remote rm origin
. 我有他们的电脑,我试图git remote rm origin
。 Then i tried git remote add origin <url>
, but it gives the following error 然后我尝试了git remote add origin <url>
,但是它给出了以下错误
fatal: remote origin already exists. 致命:远程来源已经存在。
Is there a way to push this to a new origin, and have it entirely forget about the first(like, not even remember it's a branch of the first)? 有没有办法将其推向新的起点,并完全忘记第一个(例如,甚至不记得它是第一个的分支)?
I am not clear with your problem, still giving it a try. 我不清楚您的问题,还是尝试一下。 You might not need to remove origin . 您可能不需要删除origin 。 Instead add a new one with some other name like original 而是添加一个具有其他名称(例如原始名称)的新名称
git remote add original <url>
git push -u original <branch_name>
Edit To view all the remotes use git remote -v
. 编辑要查看所有遥控器,请使用git remote -v
。 Check the remote list before adding a new remote. 在添加新的遥控器之前,请检查遥控器列表。 It will tell you which remote_name is available and which is not. 它将告诉您哪个remote_name可用,哪些不可用。
Edit2 EDIT2
If you have already added a 'git origin' to your .git configuration
. 如果您已经在.git configuration
添加了“ git origin”。 You can change the remote origin URL in your git config with the following line: 您可以使用以下行在git配置中更改远程来源URL :
git remote set-url origin git@github.com:{user}/{project}.git
To remove a remote, use git remote remove <name>
you can see more details by git help remote
要删除远程,请使用git remote remove <name>
您可以通过git help remote
查看更多详细信息
Also, I believe changing the meaning of origin
is not a best practice, if you just need to temporarily push to a new remote, just add it with another name, such as: git remote add <name> <url>
另外,我认为更改origin
的含义不是最佳做法,如果您只是需要临时推送到新的远程服务器,只需添加另一个名称即可,例如: git remote add <name> <url>
When you add a new remote
you can see it with git remote
or git remote -v
to see url details. 添加新的remote
,可以使用git remote
或git remote -v
查看它,以查看URL详细信息。
Then using git push -u <your-new-remote>
would push your repo to <your-new-remote>
然后使用git push -u <your-new-remote>
会将您的仓库推送到<your-new-remote>
EDIT: 编辑:
My fault, I didn't notice that git remote rm <name>
is also usable since it did not appear in git help remote
我的错,我没有注意到git remote rm <name>
也可用,因为它没有出现在git help remote
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.