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

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

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

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


当前回答

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

对于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

其他回答

移除远程

使用 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 remote set-url origin <project>

对于我来说,接受的答案只在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

如果您的存储库是私人

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

参考

查看 git 远程连接:

git remote -v

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

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

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

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