更改远程Git存储库的URI(URL) [英] Change the URI (URL) for a remote Git repository

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

问题描述

我在我的硬盘(本地)上克隆了USB密钥上的回购(原产地)。我把origin移到了NAS上,并成功地从这里克隆了它。



我想知道是否可以在设置中更改origin的URI 本地,所以它现在将从NAS中拔出,而不是从USB钥匙中。



现在,我可以看到两种解决方案:


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


  • 将一个新的远程添加到本地并删除旧的(我担心我会破坏我的历史记录)。 b
    $ b

    解决方案

    您可以

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

    (参见 git help remote )或者您可以编辑 .git / config 并在那里更改网址。除非你做了一些非常愚蠢的事情,否则你没有任何失去历史的危险(如果你担心,只需制作一份你的repo,因为你的repo 是你的历史。)


    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.

    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:

    • 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).

    解决方案

    You can

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

    (see git help remote) or you can just 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天全站免登陆