Git workflow

This action sequence is assembled out of my notes. I repeat it over and over again when setting up repositories on new machine. Current page is to have all this in a structured manner to follow easily. Maybe later Ill just write a program to run every step automatically. In general all this generates public and private key pairs. Then you paste those keys in your GitHub "Deploy key" section. So you can clone and use your repos inside desired machine. With or without write access. Dont forget to replace YOURNAME, YOUR@EMAIL, REPONAME and LOCALUSER with actual data.

-- Run once --
Purpose Command
Define user name and user email globally git config --global user.name "YOURNAME"
git config --global user.email "YOUR@EMAIL"
Create .ssh directory to store your keys and aliases mkdir ~/.ssh
Copy GitHub public fingerprint from https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints
And paste it to /home/LOCALUSER/.ssh/known_hosts
-- Run for every new repository --
Purpose Command
Generate public and private keys for target repo ssh-keygen -t ed25519 -C "GH_YOURNAME_REPONAME" -f ~/.ssh/id_ed25519_GH_YOURNAME_REPONAME
Add generated key to ssh keyring ssh-add ~/.ssh/id_ed25519_GH_YOURNAME_REPONAME
Config SSH agent aliases. Open /home/LOCALUSER/.ssh/config And paste(append) this Host REPONAME
Hostname github.com
IdentityFile=/home/LOCALUSER/.ssh/id_ed25519_GH_YOURNAME_REPONAME
Open /home/LOCALUSER/.ssh/id_ed25519_GH_YOURNAME_REPONAME.pub Paste its contents in https://github.com/YOURNAME/REPONAME/settings -> Settings -> Deploy keys
Now you can clone repo by running command from target folder git clone git@REPONAME:YOURNAME/REPONAME.git