如何更改远程Git存储库的URI(URL)? [英] How to change the URI (URL) for a remote Git repository?

查看:87
本文介绍了如何更改远程Git存储库的URI(URL)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的硬盘驱动器(本地)上克隆的USB密钥上有一个存储库(来源).我将起源"移至NAS并成功测试了从此处克隆它的过程.

I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved "origin" to a NAS and successfully tested cloning it from here.

我想知道是否可以在本地"设置中更改起源"的URI,以便现在可以从NAS而不是从USB密钥中提取它.

I would like to know if I can change the URI of "origin" in the settings of "local" so it will now pull from the NAS, and not from the USB key.

目前,我可以看到两种解决方案:

For now, I can see two solutions:

  • 将所有内容推送到usb-orign,然后再次将其复制到NAS(由于对nas-origin的新提交,这意味着很多工作);

  • push everything to the usb-orign, and copy it to the NAS again (implies a lot of work due to new commits to nas-origin);

在本地"中添加一个新的遥控器,并删除旧的(我担心会破坏我的历史记录.)

add a new remote to "local" and delete the old one (I fear I'll break my history).

推荐答案

您可以

git remote set-url origin new.git.url/here

(请参阅git help remote),也可以编辑.git/config并在那里更改URL.除非您做一些非常愚蠢的事情,否则您就不会失去历史记录的危险(并且,如果担心,只需复制一份您的回购书,因为您的回购书就是您的历史记录.)

(see git help remote) or you can edit .git/config and change the URLs there. You're not in any danger of losing history unless you do something very silly (and if you're worried, just make a copy of your repo, since your repo is your history.)

这篇关于如何更改远程Git存储库的URI(URL)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆