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