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

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

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

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


当前回答

从您的 repo 终端写下下下面的命令:

git remote set-url origin git@github.com:<username>/<repo>.git

请参阅此链接,以获取有关更改远程URL的详细信息。

其他回答

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


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

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

这是非常容易和简单的;只需遵循这些指示。

要添加或更改远程起源: git 远程设置 URL 起源 githubrepurl 查看您目前在本地存储库中有哪些远程 URL: git 远程显示起源

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

首先,您需要输入此命令以查看现有远程

远程 -v

然后第二,你需要输入这个命令,以更改“起源”远程的URL

git 远程设置 URL 起源 <paste 您的 GitHub URL>

对于我来说,接受的答案只在Fetch的情况下工作,但不是拖动。

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

此分類上一篇: fetch URL:

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

要更新 pull URL:

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