Git Pull via HTTPS, Git Push over SSH

This article assumes you have already setup SSH for GitHub or other Git site.

For many public Git repos, using HTTPS for git fetch, git pull and the like is adequate security. These operations occur over HTTPS perhaps twice as fast as over SSH and with lower CPU utilization. However, SSH can provide significant additional security for git push operations. Git has intrinsic functionality for many years for just this setup in a global configuration.

setup git pull HTTPS, git push SSH

  • when cloning a public repo, use https:// for the remote repo URL instead of ssh://.
  • to fix existing local public repos, edit individual repo .git/config accordingly


git config --global url."ssh://".pushInsteadOf

This makes all GitHub (or GitLab, etc.) public repos push over SSH, unless overridden in a particular repo’s push configuration. This is confirmed by git remote -v in a repo, it will show the effect of the global ~/.gitconfig.



Written by Michael Hirsch, Ph.D. //