git clone with HTTPS or SSH remote?


git clone supports both HTTPS and SSH remote URLs. Which should I use? What are the advantages of each?

GitHub's docs don't make a recommendation either way. I recall in 2013 GitHub used to recommend SSH (archive link). Why was that?


GitHub have changed their recommendation several times (example).

It appears that they currently recommend HTTPS because it is the easiest to set up on the widest range of networks and platforms, and by users who are new to all this.

There is no inherent flaw in SSH (if there was they would disable it) -- in the links below, you will see that they still provide details about SSH connections too:

  1. HTTPS is less likely to be blocked by a firewall.

    The https:// clone URLs are available on all repositories, regardless of visibility. https:// clone URLs work even if you are behind a firewall or proxy.

  2. An HTTPS connection allows credential.helper to cache your password.

    If you clone with HTTPS, you can cache your GitHub credentials in Git using a credential helper. For more information, see "Cloning with HTTPS urls" and "Caching your GitHub credentials in Git."

See changes to a specific file using git

Git push requires username and password