Sometimes I clone a repository on GitHub using the Open with GitHub Desktop functionality button as documented here on github . However, this functionality always by default clones using https instead of ssh.
So everytime I clone something I need to manually change the url. Is there a way to tell GitHub that I never want to clone with https and always want to clone with ssh?
Generic method (i.e. affecting all Git usage of GitHub repositories, not only the GitHub app):
git config --global url."[email protected]:".insteadOf "https://github.com/"
[url "[email protected]:"]
insteadOf = https://github.com/
insteadOf = git://github.com/
This will cause Git to automatically use an SSH address even if an HTTPS URL was given.
Multiple prefixes can be aliased using config --add
, e.g. I used to have a gh:
prefix so that I could do git clone gh:foo/bar
. (Wasn't very useful.)
You can also use the pushInsteadOf
option instead, so that the clone and pulls/fetches would still be done over HTTPS (faster connection establishment) while pushes will be done over SSH (using your public key).
[url "[email protected]:"]
pushInsteadOf = https://github.com/
pushInsteadOf = git://github.com/
[url "https://github.com/"]
insteadOf = git://github.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With