Clone Me Maybe

Let’s say you’re on the GitHub page for rails/rails. Copying the URL from the  top of the page, pasting it into the terminal takes too dang long! Instead, put this in your ~/.gitconfig:

# ~/.gitconfig
[url "git://github.com/"]
  # Read-only
  insteadOf = gh:

In the terminal:

$ git clone gh:rails/rails

Read/write github repos

What if I want to clone something to which I have push (write) access, like thoughtbot/high_voltage? Here you go:

# ~/.gitconfig
[url "git@github.com:"]
  # With write access
  insteadOf = wgh:
$ git clone wgh:thoughtbot/high_voltage

Easily add a Heroku remote

Now then, what if you need to add a Heroku remote for the `sushi.heroku.com` app? You could go to Heroku, log in, click “My Apps”, click “Sushi”, and find the remote URL. Or, you can do this:

# ~/.gitconfig
[url "git@heroku.com:"]
  insteadOf = heroku:
$ git remote add heroku:sushi.git

Your turn

Before I learned this tip, I missed it real bad. For more, check out my gitconfig. What are your little Git tips?

Hound automatically reviews Ruby, JavaScript, and CoffeeScript code in your GitHub pull requests and comments on style violations. It is free for open source repos and $12/month per private repo.