I would like to write an alias, either in git or in bash/zsh, which allows me to automatically prefix all my personal information to clone one of my repos. That is to say, where I type:
$ git clone [email protected]:<username>/<repo>
I would just type
$ git <alias> <repo>
or
$ <alias> <repo>
and the alias would take care of the rest.
I have tried doing this with git alias and I have tried doing this with a regular zsh alias, neither of them expanded properly. I was thinking maybe I could try a function, but I haven't gotten that far (I'm not very good with BASH).
You can do this automatically with Git's URL rewriting feature. You can add something like this to your .gitconfig
:
[url "[email protected]:bk2204/"]
insteadOf = gh:
Then, just clone with git clone gh:repo.git
and everything works. Best of all, if you later decide you'd rather use HTTPS, you can do that by just swapping the URL.