Milan Babuškov
Milan Babuškov

Reputation: 61138

Git warning: Config remote shorthand cannot begin with '/'

I just upgraded Git from some old version, and now I get this warning message whenever I pull from a remote repository:

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

This remote repository is a directory on USB stick, which I use to transfer files to computers without direct network connection. USB stick is mounted at /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)

My .git/config looks like this:

[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

I read about reasons for this change, but I don't understand what should I do to make this warning go away?

Upvotes: 1

Views: 435

Answers (2)

remgeek
remgeek

Reputation: 1

I encountered this issue when trying to fetch from a local repo:

git fetch /my/local/path my_branch

This syntax gets rid of the warning:

git fetch file:///my/local/path my_branch

But I would prefer a way to tell git to not store anything in my config about this local path.

Upvotes: 0

Brian Campbell
Brian Campbell

Reputation: 332856

I would recommend editing your .git/config to rename the remote from /mnt/titanium/repos to simply repos. The url should still be /mnt/titanium/repos, but it shouldn't have that in the actual remote name. You may need to edit the fetch reference as well:

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

edit

Now that I've seen your config, it looks like you simply have an extra remote named "/mnt/titanium/repos" in which the name and the URL of the remote are reversed, since it has a url of origin (not sure if from user error or software error). Anyhow, it looks like you don't need that at all, since the "origin" remote is defined correctly. You can delete the entire "/mnt/titanium/repos" remote (the line containing that string and following two lines), and shouldn't have any problems.

Upvotes: 4

Related Questions