Clone Me Maybe

Gabe Berke-Williams

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?

About thoughtbot

We've been helping engineering teams deliver exceptional products for over 20 years. Our designers, developers, and product managers work closely with teams to solve your toughest software challenges through collaborative design and development. Learn more about us.