Skip to content

Instantly share code, notes, and snippets.

@cararemixed
Last active November 15, 2018 15:46
Show Gist options
  • Save cararemixed/f6589bae3445390257de to your computer and use it in GitHub Desktop.
Save cararemixed/f6589bae3445390257de to your computer and use it in GitHub Desktop.
Git URL shortcuts
[url "https://github.com/"]
insteadOf = git://github.com/
insteadOf = git@github.com:
insteadOf = gh:
insteadOf = github:
[url "https://github.com/standard-analytics/"]
insteadOf = sa:
[url "https://git.apache.org/repos/asf/"]
insteadOf = apache:
[url "https://github.com/strmpnk/"]
insteadOf = my:

These shortcuts do two things. First, it translates all github ssh & git protocol based URLs with HTTPS. This is a big win when behind strict firewalls and just as efficient since GitHub runs a smart HTTP server which intelligently packs content just like the git protocol does. It also lets you use your HTTP credentials rather than dealing with SSH keys (don't forget git config --global credential.helper osxkeychain or similar depending on your platform).

The second part is more about sugar. It gives nice short names for remotes. You can do something like git clone apache:couchdb and you magically end up with the right stuff... no more memorization of that ugly ASF URL. An thing to note is that your repo's git configuration will reference the short-hand URL so if you remove the shorthand configuration it will stop working. Commands like git remote -v will still show the expanded version, but don't be fooled. You can always check your configuration file with a quick cat .git/config.

@steviesama
Copy link

steviesama commented May 26, 2016

I am running a git server, and I use git@myserver.com:reponame.git to access it. I'm trying to use the git credential.helper, but nothing I've looked up works. It still asks me for the password every time. Any clue what is going on? I know I can't access it via https, if I don't use git@, it doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment