Always learning: new git tricks
Imagine the following scenario: you keep the dotfiles for several machines under one git repo with some submodules, including one machine which clones a submodule from a GitHub repo that I own (so it's cloned over SSH, not HTTPS.) No problem when I do a recursive clone when using a key that's connected to my GitHub account - but when I'm on my gaming rig, or any other machine that is not connected, that clone URL fails as does the overall recursive clone operation. This can be "cleaned up" by hand but is a pain.
Enter url.<base>.pushInsteadOf
! With a quick one-liner or entry in your relevant git config, the above issue is solved by translating the git@github.com:
URL into https://github.com/
, seamlessly. In my case, a global change did the trick for the machines that needed it:
git config --global url."https://github.com/".insteadOf git@github.com:
Which added the following to my .gitconfig
:
[url "https://github.com/"]
insteadOf = git@github.com:
And now that machine seamlessly translates that URL to one that's usable (when cloning.) Pretty rad!