Shorter Git Remotes

Post date
Reading time
2 Minute Read
Categories
Computing

When using Bitbucket, you can end up with quite unwieldy Git URLs:

git clone ssh://git@bitbucket.example.com:7999/project/repo.git

To save copying the URL from the UI any time you clone a new repository, add the following to your ~/.ssh/config:

Host bb
    User git
    Hostname bitbucket.example.com
    Port 7999

If you’re using a separate IdentityFile, you can add this here as well.

This means clone commands can be much cleaner:

git clone bb:project/repo

The same is true for GitHub URLs:

Host gh
    User git
    Hostname github.com

And the clone command is the same:

git clone gh:username/repository

Leave a Reply