如何从 Git 存储库中删除远程源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16330404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove remote origin from Git repo
提问by Om3ga
I just did git init
to initialize my folder as git repo and then added a remote repository using 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
. How can I do it?
我只是git init
将我的文件夹初始化为 git repo,然后使用git remote add origin url
. 现在我想删除它git remote add origin
并添加一个新的存储库git remote add origin new-url
。我该怎么做?
回答by kahowell
Instead of removing and re-adding, you can do this:
您可以执行以下操作,而不是删除和重新添加:
git remote set-url origin git://new.url.here
See this question: How to change the URI (URL) for a remote Git repository?
请参阅此问题:如何更改远程 Git 存储库的 URI (URL)?
To remove remote use this:
要删除远程使用此:
git remote remove origin
回答by 1615903
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 answeris better.
但卡豪威尔的回答更好。
回答by Vontei
To remove a remote:
删除遥控器:
git remote remove origin
To add a remote:
添加遥控器:
git remote add origin yourRemoteUrl
and finally
最后
git push -u origin master
回答by Manish Kakati
you can try this out,if you want to remove origin and then add it:
你可以试试这个,如果你想删除原点然后添加它:
git remote remove origin
then:
然后:
git remote add origin http://your_url_here
回答by heroin
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". So the correct way is:
我没有足够的声誉来评论@user1615903 的答案,因此将其添加为答案:“git remote remove”不存在,应使用“rm”而不是“remove”。所以正确的做法是:
git remote rm origin
回答by Anshul Bisht
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
回答by Nasir Khan
To set a origins remote url-
设置 origins 远程 url-
git remote set-url origin git://new.url.here
here origin is your push url name. You may have multiple origin. If you have multiple origin replace origin as that name.
这里的 origin 是你的推送 url 名称。您可能有多个来源。如果您有多个原点,请将原点替换为该名称。
For deleting Origin
用于删除原点
git remote rm origin/originName
or
git remote remove origin/originName
For adding new origin
用于添加新原点
git remote add origin/originName git://new.url.here / RemoteUrl
回答by Krishna Kamal
perhaps I am late
you can use git remote remove origin
it will do the job.
也许我迟到了,您可以使用git remote remove origin
它来完成这项工作。
回答by Yasin UYSAL
Another method
另一种方法
Cancel local git repository
取消本地 git 存储库
rm -rf .git
Then; Create git repostory again
然后; 再次创建 git 仓库
git init
Then; Repeat the remote repo connect
然后; 重复远程仓库连接
git remote add origin REPO_URL
回答by Hamit YILDIRIM
first will change push remote url
首先将更改推送远程 url
git remote set-url --push origin https://newurl
second will change fetch remote url
第二个将更改获取远程 url
git remote set-url origin https://newurl