1

我刚刚从某个旧版本升级了 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/titanium

$ 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

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

4

1 回答 1

4

我建议您编辑您.git/config的遥控器以将遥控器重命名/mnt/titanium/repos为 simple 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"遥控器(包含该字符串的行和后面的两行),应该没有任何问题。

于 2013-10-22T10:47:06.420 回答