Authenticating with Git

There are many ways to authenticate with Git when pushing to remote repositories. See some of the below for examples.

Credential Caching

If you don’t want to authenticate every time you push, you can set up a “credential cache”. The simplest is just to keep it in memory for a few minutes, which you can easily set up by running git config --global credential.helper cache.

SSH Keys

You can use ssh-keygen to generate a key and the manually add the key to your GitHub profile.
To do this, run ssh-keygen -t ed25519 and follow the prompts. Be sure to include the file path when naming your key, or the key will be output into your working directory. Once generated, simply cat and copy / paste your public key into the field within your settings on GitHub.To do this, you'll need to run git remote set-url origin in order to configure your local repository to use SSH private keys when connecting to git. For more on ssh-keygen, check out Creating SSH Login Keys.

Personal Access Tokens

Alternatively, you could generate a static Personal Access Token - a token that once generated can be paired with a YubiKey or similar product. This allows you to clone / work from anywhere without having to provision or SSH keys or manage long passwords / 2FA methods. Plug your key into USB and tap your desired configuration and the static access key will be input, allowing immediate access for this one time. So, every time you push, unless you configure otherwise, you will have to enter this token by tapping the YubiKey.