代码之家  ›  专栏  ›  技术社区  ›  doekman

是什么把“[url…]而不是=…”添加到了我的.gitconfig文件中?

  •  1
  • doekman  · 技术社区  · 6 年前

    最近,我在命令行和GitHub桌面上收到了来自git的奇怪错误。让我们关注命令行(repo在GitHub上分叉):

    $ git fetch upstream
    repository does not exist.
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    奇怪的。当我通过 git config --get remote.upstream.url ,我得到了正确的URL。然而, git remote show upstream fetch git remote show -n upstream ,我得到了一些混乱的网址:

    * remote upstream
      Fetch URL: git@bitbucket.org:doekman/mac-bin.gitgithub.com/secretGeek/ok-bash.git
      Push  URL: git@bitbucket.org:doekman/mac-bin.gitgithub.com/secretGeek/ok-bash.git
    

    第一个URL(git@bitbucket.org:doekman/mac bin.git)是我自己的存储库,但与我正在使用的存储库无关,另一部分(github.com/secretGeek/ok bash.git)是我需要的上游URL。

    GitHub桌面检测到错误,并建议修复它,但当我按fix时,什么也没有发生。

    奇怪的是 .git/config 文件看起来还好吧?

    我可以重新整理这个存储库,并重新配置上游,但我想知道这是如何发生的和/或这是如何工作的。

    mac-bin .git 文件夹什么也没做,我四处看看,发现下面的内容已经添加到了我的文件夹中 ~/.gitconfig 文件。

    是什么导致了这些行被添加。我肯定没有加这些:

    [url "git@bitbucket.org:doekman/mac-bin.git"]
        insteadOf = https://
    [url "https://<GITUSERNAME>@"]
        insteadOf = git://
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   VonC    6 年前

    正确的insteadOf需要的不仅仅是URL方案(https://或SSH://),而是要替换的正确URL)

    如果可以,请从配置文件中删除这些指令而不是指令。

    git config -l --show-origin