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

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

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

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


当前回答

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

開啟 Team Explorer (Ctrl + M)

Home > 设置

Git -> 存储器设置

此分類上一篇: Edit

此分類上一篇

其他回答

更改远程 git URI 到 git@github.com 而不是 https://github.com

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

例子:

git remote set-url origin git@github.com:Chetabahana/my_repo_name.git

优点是,当您使用 ssh 代理时,您可以自动进行 git push :

#!/bin/bash

# Check ssh connection
ssh-add -l &>/dev/null
[[ "$?" == 2 ]] && eval `ssh-agent`
ssh-add -l &>/dev/null
[[ "$?" == 1 ]] && expect $HOME/.ssh/agent

# Send git commands to push
git add . && git commit -m "your commit" && git push -u origin master

插入一个脚本文件 $HOME/.ssh/agent 让它运行 ssh-add 使用预期如下:

#!/usr/bin/expect -f
set HOME $env(HOME)
spawn ssh-add $HOME/.ssh/id_rsa
expect "Enter passphrase for $HOME/.ssh/id_rsa:"
send "<my_passphrase>\n";
expect "Identity added: $HOME/.ssh/id_rsa ($HOME/.ssh/id_rsa)"
interact

正如我们在这里看到的那样,

$ git remote rm origin
$ git remote add origin git@github.com:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master

移除远程

使用 git 远程 rm 命令从您的存储库中删除远程 URL。

    $ git remote -v
    # View current remotes
    > origin  https://github.com/OWNER/REPOSITORY.git (fetch)
    > origin  https://github.com/OWNER/REPOSITORY.git (push)
    > destination  https://github.com/FORKER/REPOSITORY.git (fetch)
    > destination  https://github.com/FORKER/REPOSITORY.git (push)

    $ git remote rm destination
    # Remove remote
    $ git remote -v
    # Verify it's gone
    > origin  https://github.com/OWNER/REPOSITORY.git (fetch)
    > origin  https://github.com/OWNER/REPOSITORY.git (push)

查看 git 远程连接:

git remote -v

现在,将本地存储库设置为远程 git:

git remote set-url origin https://NewRepoLink.git

现在让它升级或按下使用下列代码:

git push --set-upstream 起源大师 -f

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


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

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