Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make GitHub desktop use ssh by default?

Tags:

git

github

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?

like image 779
M.D. Avatar asked Sep 15 '25 12:09

M.D.


1 Answers

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/
like image 77
user1686 Avatar answered Sep 17 '25 04:09

user1686