github and Ubuntu 22.04
github does not permit authentication via passwords, but we can use a classic token.
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic
Note: I already had a token, but it cannot be recalled on the web page, so generated a new token.
Create a new classic token:
Log into github
https://github.com/
click on your profile photo and choose Settings
Click on Developer settings.
Click on Personal access tokens, choose classic token
Click on Generate new token and choose Generate new token (classic)
Choose a name, expiration, and scope, and click on Generate token
and copy it to the clipboard or save it elsewhere.
Install GitHub CLI
"Caching your GitHub credentials in Git."
https://github.com/cli/cli/blob/trunk/docs/install_linux.md
Install curl
sudo apt install curl
Run
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd
of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg]
https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
\
&& sudo apt update \
&& sudo apt install gh -y
Run GitHub CLI
gh auth login
Using the previously generated classic token, get
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
The minimum required scopes are 'repo', 'read:org', 'workflow'.
? Paste your authentication token: ****************************************
- gh config set -h github.com git_protocol https
Configured git protocol
Logged in as atmelino
Install git
sudo apt install git
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Test development cycle
git clone https://github.com/atmelino/atmelino.github.io.git
Edit a file
Run
git add --all
git commit -m "update"
git push -u origin main
Create new repository
Log in to github.
Create new repository
Make sure to init as recommended.
Click on Code button and copy repository link.
git clone [paste copied text here]
Working with local repository
Upload changed code to github
git add --all
git commit -m "update"
git push -u origin main
Update local repository from github
git pull
Undo local changes
Check status
git status
If the message is
Changes not staged for commit:
run
git restore *
and check status again, should say
Your branch is up to date with 'origin/main'.
gh update error
sudo apt update
Error messages
Err:3 https://cli.github.com/packages stable InRelease
The following signatures were invalid: EXPKEYSIG 23F3D4EA75716059 GitHub CLI <opensource+cli@github.com>
W: An error occurred during the signature verification. The repository is not updated and the previous index
files will be used. GPG error: https://cli.github.com/packages stable InRelease: The following signatures were
invalid: EXPKEYSIG 23F3D4EA75716059 GitHub CLI <opensource+cli@github.com>
W: Failed to fetch https://cli.github.com/packages/dists/stable/InRelease The following signatures were
invalid: EXPKEYSIG 23F3D4EA75716059 GitHub CLI <opensource+cli@github.com>
Solution
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) && sudo mkdir -p -m 755
/etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee
/etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null && sudo chmod go+r
/etc/apt/keyrings/githubcli-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture)
signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo
tee /etc/apt/sources.list.d/github-cli.list > /dev/null && sudo apt update && sudo apt install gh -y
https://github.com/cli/cli/blob/34d7ef7a0efb07b5be163d971c97df0c64655abd/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt