我在我的硬盘上(本地)克隆的USB键上有一个repo(起源)。我将“起源”转移到NAS,并成功测试了从这里克隆。

我想知道我是否可以在“本地”设置中更改“起源”的URI,所以它现在将从NAS中拖动,而不是从USB键。

到目前为止,我可以看到两个解决方案:

把一切推到USB起源,然后将其复制到NAS(这意味着由于NAS起源的新承诺而付出很多工作);添加一个新的远程到“本地”并删除旧的(我担心我会打破我的历史)。


当前回答

您可以通过编辑 config 文件来更改 URL。

nano .git/config

然后编辑 url 字段并设置新的 url. 保存更改. 您可以使用命令验证更改。

git remote -v 

其他回答

在 Git Bash 中,输入命令:

git 远程设置 URL 起源 https://NewRepoLink.git

输入信号

达尼

对于那些想要从 Visual Studio 2019 进行此更改的人来说

開啟 Team Explorer (Ctrl + M)

Home > 设置

Git -> 存储器设置

此分類上一篇: Edit

此分類上一篇

如果你克隆了你的本地将自动组成,

远程 URL 在那里它被克隆。

您可以使用 git remote -v 查看。

如果你想改变它,

git remote set-url origin https://github.io/my_repo.git

这里,

起源 - 你的分支

如果你想重写现有分支,你仍然可以使用它......它会重写你的现有分支......它会

git remote remove url
and 
git remote add origin url

為你...

更改远程上流: git 远程设置 URL 起源 <url>


要添加更多升级: git remote 添加新位置 <url>

因此,您可以选择在哪里工作 git push 起源 <branch> 或 git push newplace <branch>

git remote -v
# View existing remotes
# origin  https://github.com/user/repo.git (fetch)
# origin  https://github.com/user/repo.git (push)

git remote set-url origin https://github.com/user/repo2.git
# Change the 'origin' remote's URL

git remote -v
# Verify new remote URL
# origin  https://github.com/user/repo2.git (fetch)
# origin  https://github.com/user/repo2.git (push)

更改远程的URL