The first thing to do is to authenticate with GitHub. This can be done in two ways:
- SSH, with a private key (preferred)
- HTTPS, with a Personal Access Token (PAT)
git config --set user.name <username>
ℹ️ This is the name your commits will show up as
git config --set user.email <user@domain.com>
When you run a git pull or a git fetch, Git will ask for your password.
Screenshot 2024-11-13 alle 09.05.50.png
⚠️ When you generate a token, GitHub will only display it once. Make sure to store it somewhere safe!
Here you can generate a Personal Access Token, to then copy and paste into the Terminal.
Note: the terminal will NOT display the token, for privacy reasons.
Generate an SSH key-pair, as follows:
$ ssh-keygen -t ed25519 -C "user@domain.com"Follow the guided procedure with the ssh-keygen tool and finish creating a key.
The tool will then have generated the two important files:
id_ed25519.pub: the public key we’ll upload to GitHubid_ed25519: the private key we keep locally!
This is where you’ll add a new SSH public key that GitHub will accept the private counterpart for.
Screenshot 2024-11-13 alle 09.11.49.png
Finally, add the new SSH key to your SSH agent:
# Start the agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid XXXXX
# Add the key
$ ssh-add ~/.ssh/id_ed25519If you don’t want to run the
ssh-agentevery time, you may add the command above to start it into your~/.bashrc/~/.zshrcfile, to have it run automatically.
- Commit signing with the same key
- More versatile than a Personal Access Token
- More private (encrypted secret — SSH key never leaves your machine)