Git URL Shortcuts

You can create shortcuts for git URL paths to clone without typing full URL.

Add the following to your .gitconfig file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
[url "https://github.com/"]
    insteadOf = github:
    insteadOf = gh:

[url "git@github.com:"]
    pushInsteadOf = github:
    pushInsteadOf = gh:

[url "https://gitlab.com/"]
    insteadOf = gitlab:
    insteadOf = gb:

[url "git@gitlab.com:"]
    pushInsteadOf = gitlab:
    pushInsteadOf = gb:
1
2
3
4
# With this configuration, you can clone your repositories using url shortcuts
git clone gh:l-lin/dotfiles
# instead of
git clone git@github.com:l-lin/dotfiles