【问题标题】:How to debug git remote set-url not working如何调试 git remote set-url 不起作用
【发布时间】:2019-06-23 13:18:07
【问题描述】:

我无法将 git 远程 URL 从 git:// 更改为 https://

如下图所示,git remote set-url 不起作用:

$ git remote -v

来源 git://github.com/userName/repoName.git (fetch)

来源 git://github.com/userName/repoName.git(推送)

$ git remote set-url origin https://github.com/userName/repoName.git

$ git remote -v

来源 git://github.com/userName/repoName.git (fetch)

来源 git://github.com/userName/repoName.git(推送)

我也试过移除遥控器并重新添加它,但无济于事。

.git/config

[remote "origin"]
    url = https://github.com/userName/repoName.git
    fetch = +refs/heads/*:refs/remotes/origin/*

我检查了许多关于git remote set-url 的查询,但没有一个处理set-url 不起作用的问题。

【问题讨论】:

    标签: git github


    【解决方案1】:

    使用命令(您可能必须在 Windows 操作系统上使用管理权限,或在 macOS 或 Linux 上使用sudo 权限)

    git remote add upstream https://example.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
    

    https://help.github.com/articles/configuring-a-remote-for-a-fork/

    【讨论】:

      【解决方案2】:

      已解决

      从运行 $ git config --list 开始,我意识到 .git/config 正在强制 git 重命名所有遥控器。 See here for more information.

      要解决此问题,您可以:

      1. 手动编辑文件:git config --global --edit
      2. 删除部分:git config --global --remove-section url."git://github.com/"

      第二个选项更可取,因为它比直接编辑 git 配置文件更安全。

      【讨论】:

      • 非常感谢!我花了一段时间才意识到我的原始获取设置为 repo.git 而不是实际的 repo 名称。这是因为我有一个全局配置以某种方式保存到 repo.git,这阻止了我使用 set-url 进行更改。
      猜你喜欢
      • 1970-01-01
      • 2020-10-08
      • 2014-03-27
      • 1970-01-01
      • 2011-04-14
      • 1970-01-01
      • 2017-09-12
      • 2020-09-08
      • 2022-10-19
      相关资源
      最近更新 更多