Authentication
GitHub doesn’t allow password authentication anymore to authenticate. Instead, it requires the use of personal access tokens that are more granular in their permissions.
- We can create a new token with
Settings > Developer settings > Personal access tokens. We create a fine-grained token for private repositories we own, and a classic token for organisation repositories.- If modifying files (i.e., committing, pushing, pulling), be sure to tick relevant checkboxes. Most other settings can be left unchecked.
- Then, in our local repository, we need to slightly modify how we pull/push via HTTPS.
git remote -vlists the remote sources.git remote remove originwill remove the origin link.git remote set-url origin https://personal-access-token@github.com/your-repo.gitwill allow us to push/pull with the personal access token. This lets us bypass needing to enter it every time.
We can also use SSH keys.
- Once we see the public key, we can add it to our GitHub account.
Settings > SSH and GPG keys > New SSH key. There, we paste our public key.- We test the SSH connection with
ssh -T git@github.com.