Git 警告:配置远程速记不能以 '/' 开头



>我刚刚从某个旧版本升级了 Git,现在每当我从远程仓库中提取时,我都会收到此警告消息:

$ git pull
warning: Config remote shorthand cannot begin with '/': /mnt/titanium/repos.url
warning: Config remote shorthand cannot begin with '/': /mnt/titanium/repos.fetch

这个远程存储库是 U 盘上的一个目录,我用它来将文件传输到没有直接网络连接的计算机。U 盘安装在/mnt/钛金属上

$ git remote -v
warning: Config remote shorthand cannot begin with '/': /mnt/titanium/repos.url
warning: Config remote shorthand cannot begin with '/': /mnt/titanium/repos.fetch
origin  /mnt/titanium/repos (fetch)
origin  /mnt/titanium/repos (push)

我的 .git/config 看起来像这样:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[branch "master"]
[remote "/mnt/titanium/repos"]
        url = origin
        fetch = refs/heads/*:refs/remotes//mnt/titanium/repos/*
[remote "origin"]
        url = /mnt/titanium/repos
        fetch = refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

我阅读了有关此更改的原因,但我不知道该怎么做才能使此警告消失?

我建议编辑您的.git/config,将遥控器从/mnt/titanium/repos重命名为简单的repos。url 仍应/mnt/titanium/repos,但它不应在实际的远程名称中包含该名称。您可能还需要编辑fetch引用:

[remote "repos"]
    url = /mnt/titanium/repos
    fetch = +refs/heads/*:refs/remotes/repos/*

编辑

现在我已经看到了您的配置,看起来您只是有一个名为 "/mnt/titanium/repos" 的额外遥控器,其中遥控器的名称和 URL 是相反的,因为它的 url 为 origin(不确定是来自用户错误还是软件错误)。无论如何,看起来您根本不需要它,因为"origin"遥控器的定义正确。您可以删除整个"/mnt/titanium/repos"远程(包含该字符串和以下两行的行),并且应该没有任何问题。

最新更新