Rewrite git repo URLs

A question in a mail list I’m on introduced me to a git feature that was very new to me: it’s possible to have git rewrite the repository URLs to always use HTTPS or git+ssh, etc.

This one-liner seems to force https:

git config --global url.https://github.com/.insteadOf git://github.com/

Or you can add these to your .gitconfig:

# Use https instead of git and git+ssh
[url "https://github.com/"]
  insteadOf = git://github.com/
[url "https://github.com/"]
  insteadOf = git@github.com:

# Use git and git+ssh instead of https
[url "git://github.com/"]
  insteadOf = https://github.com/
[url "git@github.com:"]
  pushInsteadOf = "git://github.com/"
[url "git@github.com:"]
  pushInsteadOf = "https://github.com/"