本文翻译自:How to remove remote origin from Git repo
I just did git init
to initialize my folder as git repo and then added a remote repository using git remote add origin url
. 我只是使用git init
将我的文件夹初始化为git repo,然后使用git remote add origin url
添加了一个远程存储库。 Now I want to remove this git remote add origin
and add a new repository git remote add origin new-url
. 现在,我想删除此git remote add origin
并添加一个新的存储库git remote add origin new-url
。 How can I do it? 我该怎么做?
#1楼
参考:https://stackoom.com/question/16WHc/如何从Git存储库中删除远程源
#2楼
Instead of removing and re-adding, you can do this: 您可以执行以下操作,而不是删除并重新添加:
git remote set-url origin git://new.url.here
See this question: Change the URI (URL) for a remote Git repository 看到这个问题: 更改远程Git存储库的URI(URL)
#3楼
If you insist on deleting it: 如果您坚持要删除它:
git remote remove origin
Or if you have Git version 1.7.10 or older 或者,如果您的Git版本为1.7.10或更旧
git remote rm origin
But kahowell's answer is better. 但是, kahowell的答案更好。
#4楼
I don't have enough reputation to comment answer of @user1615903, so add this as answer: "git remote remove" does not exist, should use "rm" instead of "remove". 我没有足够的声誉来评论@ user1615903的答案,因此请将其添加为答案:“ git remote remove”不存在,应使用“ rm”而不是“ remove”。 So the correct way is: 因此正确的方法是:
git remote rm origin
#5楼
You can rename (changing URL of a remote repository) using : 您可以使用以下命令重命名(更改远程存储库的URL):
git remote set-url origin new_URL
new_URL can be like https://github.com/abcdefgh/abcd.git new_URL可以像https://github.com/abcdefgh/abcd.git
Too permanently delete the remote repository use : 太永久性地删除了远程存储库的使用:
git remote remove origin
#6楼
To remove a remote: 删除遥控器:
git remote remove origin
To add a remote: 要添加遥控器:
git remote add origin yourRemoteUrl
and finally 最后
git push -u origin master