This article assumes you have already setup SSH for GitHub or other Git site.
For many public Git repos, using HTTPS for
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.
git pull HTTPS,
git push SSH
- when cloning a public repo, use
https://for the remote repo URL instead of
- to fix existing local public repos, edit individual repo
git config --global url."ssh://github.com/".pushInsteadOf https://github.com/
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