Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
382 views
in Technique[技术] by (71.8m points)

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

I have a repo (origin) on a USB key that I cloned on my hard drive (local).

(我在硬盘驱动器(本地)上克隆的USB密钥上有一个回购(来源)。)

I moved "origin" to a NAS and successfully tested cloning it from here.

(我将“起源”移至NAS并成功测试了从此处克隆它的过程。)

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.

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

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);

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

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

    (在“本地”中添加新的遥控器,然后删除旧的遥控器(我担心会破坏我的历史记录)。)

  ask by e-satis translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can

(您可以)

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

(see git help remote ) or you can just edit .git/config and change the URLs there.

((请参阅git help remote ),也可以只编辑.git/config并在那里更改URL。)

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

(除非您做一些非常愚蠢的事情,否则您不会失去历史记录的危险(并且,如果担心,只需复制一份您的回购协议,因为您的回购协议就是您的历史记录。))


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...