But how do we authenticate?

There are different ways to authenticate to web services

The most popular ones are:

Others include the using Local Protocol and the Git Protocol

HTTPS

You can use your username and password/token to authenticate over HTTPS.

To avoid having to repeat this process every time, you can use the Git Credential Manager, which will cache your credentials for you.

Setup info: GitHub

HTTPS

GitHub recommends using HTTPS in their docs, but it supports SSH too.

Pros of using HTTPS:

*GitHub requires you to use PATs when authenticating over HTTPS

SSH

You can also authenticate using SSH keys.

To do that, you can just upload your public SSH key to the service you're using.

Just remember to use the SSH URL when cloning your repositories.

Setup info: GitHub, GitLab

SSH

GitLab recommends using SSH but, like GitHub, it supports both ways.

Pros of using SSH: