如何从Git存储库中删除远程源

本文介绍了如何从Git仓库中删除远程源,并提供了不同版本Git的相应操作命令,包括使用`git remote rm`或`git remote set-url`来管理远程仓库。
摘要由CSDN通过智能技术生成

本文翻译自: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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值