A helpful git config snippet

So, if you’re like me, you like to poke through the source of things from time to time but you always forget what the proper URL is for, say, GNOME git. Or Fedora hosted. Or whatever.

Well, good news, friend! Stuff this into your ~/.gitconfig and make your life a bit easier:

[url "git://git.fedorahosted.org/git/"]
        insteadOf = "fh:"
[url "ssh://git.fedorahosted.org/git/"]
        insteadOf = "fh-ssh:"
[url "git://git.gnome.org/"]
        insteadOf = "gnome:"
[url "ssh://git.gnome.org/git/"]
        insteadOf = "gnome-ssh:"
[url "git://anongit.freedesktop.org/git/"]
        insteadOf = "fdo:"
[url "ssh://git.freedesktop.org/git/"]
        insteadOf = "fdo-ssh:"

Now you can do stuff like git clone fdo:plymouth or git clone fh-ssh:autoqa.git and it should Just Work*. Neat!

Now, if I was really clever, I’d find somewhere to ship this in the default Fedora install, or at least as part of the developer tools. Maybe someone else out there is really clever?

*Unless your local username is different from the remote username, in which case ssh might not work – but you can fix that by changing the url to ssh://username@... or putting the following in ~/.ssh/config:

Host *.freedesktop.org
        User username


3 thoughts on “A helpful git config snippet

  1. You can also make git fetch over the faster git:// and still push over ssh:// with the same name:

    [url "git://git.fedorahosted.org/git/"]
            insteadOf = "fh:"
    [url "ssh://git.fedorahosted.org/git/"]
            pushInsteadOf = "fh:"
  2. Need an /etc/gitconfig.d/
    There’s a $(prefix)/etc/gitconfig file that git reads, but it would be nice to be able to drop this stuff into e.g. /etc/gitconfig.d/ instead.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s