Git Pull via HTTPS, Git Push over SSH

less than 1 minute read

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

one-time:

git config --global url."ssh://github.com/".pushInsteadOf https://github.com/

This makes all github.com 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.

Tags:

Categories:

Updated:

Leave a comment