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

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

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

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


当前回答

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

其他回答

在 Git Bash 中,输入命令:

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

输入信号

达尼

如果您的存储库是私人

从启动菜单中打开控制面板 选择用户帐户 在左手菜单中选择“管理您的认证” 删除与 Git 或 GitHub 相关的任何认证

参考

这个答案属于一个问题,我无法在其他地方找到答案:做这个项目在Gitlab,有一个子组。

git remote add origin git@gitlab.com:group/subgroup/project.git

与所有有“用户名”而不是“组”的答案相反,没有一个通过SSH为我工作。

git remote add origin https://username@gitlab.com/group/subgroup/project.git

请注意两者之间的区别是 ".com:group" 和 ".com/group" 。

如果这不是直接从盒子上工作,我使用了HTTPS方法之前成功使用SSH一个,可能是一个因素,但我不能生气尝试并重复它没有它。

此分類上一篇: git remote set-url {name} {url}

git remote set-url origin https://github.com/myName/GitTest.git

它会很好,你可以尝试这个

对于SSH:

命令: git 远程设置 URL 起源 <ssh_url>

例如: git 远程设置 URL 起源 git@github.com:username/rep_name.git

对于HTTPS:

命令: git 远程设置 URL 起源 <https_url>

例如: git 远程设置 URL 起源 https://github.com/用户名/REPOSITORY.git