Git setup cheatsheet
Generating & adding SSH key
-
Generate SSH key
ssh-keygen -t ed25519 -C "email@domain.com"
-
Start ssh-agent if necessary
eval "$(ssh-agent -s)"
-
Add SSH key to ssh-agent
ssh-add ~/.ssh/id_ed25519
-
Copy echoed SSH public key
cat ~/.ssh/id_ed25519.pub
-
Add to github account
https://github.com/settings/keys
Generating & adding GPG key
-
Generate GPG key
gpg --full-generate-key
-
List secret keys and copy the key ID
gpg --list-secret-keys --keyid-format=long
sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10]
-
Export then copy GPG key ID
gpg --armor --export 3AA5C34371567BD2 > gpg.key
-
Add to github account
https://github.com/settings/keys
-
Tell git about the GPG key
Migrate existing GPG key
-
Export public key into public.key
gpg --export -a $KEY_UID > public.key
-
Export private key into public.key
gpg --export-secret-key -a $KEY_UID > private.key
-
Modify encoding if needed
-
Import public key
gpg --import public.key
-
Import private key
gpg --import private.key
-
Tell git about the GPG key
Add GPG key to Git CLI
-
List secret keys and copy the key ID
gpg --list-secret-keys --keyid-format=long
sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10]
-
Set GPG signing key in Git
git config --global user.signingkey 3AA5C34371567BD2
-
To sign commits by default
git config --global commit.gpgsign true
Login to Git CLI
-
Add username to Git
git config --global user.name "username"
-
Add email to Git
git config --global user.email "email@domain.com