我在我的硬盘上(本地)克隆的USB键上有一个repo(起源)。我将“起源”转移到NAS,并成功测试了从这里克隆。
我想知道我是否可以在“本地”设置中更改“起源”的URI,所以它现在将从NAS中拖动,而不是从USB键。
到目前为止,我可以看到两个解决方案:
把一切推到USB起源,然后将其复制到NAS(这意味着由于NAS起源的新承诺而付出很多工作);添加一个新的远程到“本地”并删除旧的(我担心我会打破我的历史)。
我在我的硬盘上(本地)克隆的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 remote set-url sofake https://github.com/octocat/Spoon-Knife fatal: 没有这样的遥远的“sofake”
确保您正确输入了远程名称。
参考 : https://help.github.com/文章/变更-a-remote-s-url/
git remote set-url origin git://new.location
(替代,打开.git/config,搜索 [远程“起源”),并编辑 url = 行。
你可以检查它工作,通过检查远程:
git remote -v
# origin git://new.location (fetch)
# origin git://new.location (push)
接下来的按钮,你将不得不指定新的上流分支,例如:
git push -u origin master
此分類上一篇: GitHub: 更改遠程 URL
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 remote set-url origin [Here new url]
只需确保您在存储库的位置打开了它。
确认
它被放置在.git/config (与存储库相同的文件夹)
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = [Here new url] <------------------------------------
...
可口可乐
此分類上一篇
此分類上一篇
然后编辑URL。
源树
点击“设置”按钮在工具栏上打开仓库设置窗口. 点击“添加”添加一个远程仓库路径到仓库. 一个“远程详细”窗口将打开. 输入一个名称的远程路径. 输入 URL/路径的远程仓库 输入用户名的托管服务的远程仓库. 点击“OK”添加远程路径。
此分類上一篇
此分類上一篇
ref. 支持
(仅限 Windows PS) 在所有本地休息室中重复更改服务器/协议
Get-ChildItem -Directory -Recurse -Depth [Number] -Hidden -name | %{$_.replace("\.git","")} | %{git -C $_ remote set-url origin $(git -C $_ remote get-url origin).replace("[OLD SERVER]", "[NEW SERVER]")}