GitHub Cheat Sheet

Server Edition — SSH only

Logging in with GitHub CLI (headless servers)

gh auth login -h github.com

Choose:

Check status:

gh auth status

Converting a remote to SSH

git remote add origin git@github.com:theo-langstraat/{repository}.git
git remote set-url origin git@github.com:theo-langstraat/{repository}.git

Verify:

git remote -v

Pushing to GitHub

git add .
git commit -m "type: subject"
git push

If pushing fails because histories differ:

git push --force origin main

Commitlint follows the Conventional Commits specification. A commit message must contain at least:

  • type — category of the change (lowercase)

  • subject — short description (lowercase)

Valid types include:

  • feat — new functionality

  • fix — bug fix

  • docs — documentation

  • chore — maintenance

  • refactor — code restructuring

  • test — test files

  • build — build system

  • ci — CI configuration


Creating a release with GitHub CLI

gh release create 1.0.0 build/dailyverses-1.0.0.zip --notes "Initial release"

Upload release assets:

gh release upload 1.0.0 build/dailyverses-1.0.0.zip

Fixing gh-auth issues

Reset configuration

rm -rf ~/.config/gh
mkdir ~/.config/gh
chmod 700 ~/.config/gh

Remove text browsers (prevents login crashes)

sudo apt remove w3m lynx links elinks links2

Debugging

GITHUB_DEBUG=1 gh auth login -h github.com

Checking Git

View remotes

git remote -v

Push branch

git push -u origin main

Test SSH

ssh -T git@github.com

Useful Git commands

New branch

git checkout -b feature/name

Delete branch

git branch -d feature/name

Amend last commit

git commit --amend

Using stash

git stash
git stash pop

Server tips

  • Always run gh auth login from your home directory

  • Always use SSH for Git

  • Never copy GitHub instructions that use https://

  • Remove text browsers on headless servers

  • gh auth status is your best friend

Diversen

 1gh auth login
 2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
 3git init
 4gh repo create calimporter --public --source=. --push
 5
 6git add .
 7git commit -m "Dynamic flexfroms moved outside extension to var/"
 8git branch -M main
 9git remote add origin https://github.com/theo-langstraat/dailyverses.git
10git push -u origin main
11
12^` or create a new repository on the command line
13
14echo "# test" >> README.md
15git init
16git add README.md
17git commit -m "first commit"
18git branch -M main
19git remote add origin https://github.com/theo-langstraat/test.git
20git push -u origin main
21^` or push an existing repository from the command line
22
23git remote add origin https://github.com/theo-langstraat/test.git
24git branch -M main
25git push -u origin main