Cheat sheet
Generated from the cheat field of every scenario. Use your browser's Print (Ctrl+P) to save it as a PDF.
Git & GitHub · First-time setup
Install and configure Git (first time)
terminal
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main Sign in to GitHub from Windows
terminal
gh auth login
gh auth statusGit & GitHub · New project
Create a repo and push a new project to GitHub
terminal
git init -b main
git add -A
git commit -m "Initial commit"
gh repo create my-site --private --source=. --remote=origin --push Clone an existing project to a new computer
terminal
git clone https://github.com/USER/REPO.git
cd REPO
npm installGit & GitHub · Daily workflow
Save my changes: commit and push
terminal
git status
git add -A
git commit -m "Describe the change"
git push Put unfinished work aside (stash)
terminal
git stash push -u -m "wip"
git stash list
git stash popGit & GitHub · What did I do?
What did I do? Read status, log and diff
terminal
git status -sb
git log --oneline --graph -n 15
git diff
git diff --staged What changed since my last push, or on GitHub?
terminal
git fetch
git log origin/main..HEAD --oneline
git log HEAD..origin/main --oneline Find when (and why) something changed
terminal
git log -p -- path/to/file
git log -S"text" --oneline
git blame path/to/file
git log --since="2 weeks ago" --onelineGit & GitHub · Sync with remote
Fetch or pull? Get GitHub's changes safely
terminal
git fetch
git pull
git pull --ff-only I changed things and GitHub changed too: pull, merge, push
terminal
git status
git add -A
git commit -m "msg"
git pull --no-rebase
git push Update my feature branch with the latest main
terminal
git switch main
git pull
git switch my-branch
git merge main Merge my finished branch into main and push
terminal
git switch main
git pull
git merge my-branch
git push Rebase or merge? Which one should I use
terminal
git merge main
git rebase main
git rebase --abortGit & GitHub · Branches
Create and switch branches
terminal
git switch -c my-branch
git switch main
git branch -vv
git push -u origin my-branch Branch, pull request, preview, merge (safest flow for a live site)
terminal
git switch -c my-change
git push -u origin my-change
gh pr create --fill
gh pr merge --squash --delete-branch Delete old branches (local and on GitHub)
terminal
git branch -d my-branch
git push origin --delete my-branch
git fetch --pruneGit & GitHub · Fix mistakes
Undo my last commit (not pushed yet)
terminal
git reset --soft HEAD~1
git commit --amend -m "new message" Undo a commit that is already pushed (revert)
terminal
git revert <commit-id>
git push Unstage a file or discard my edits
terminal
git restore --staged file
git restore file
git clean -nd Recover lost commits with the reflog
terminal
git reflog
git switch -c rescue <commit-id>Git & GitHub · Conflicts & rejections
Resolve a merge conflict
terminal
git status
git add <file>
git commit
git merge --abort Push rejected (non-fast-forward / fetch first)
terminal
git pull --no-rebase
git pushGit & GitHub · Housekeeping
Keep files and secrets out of Git (.gitignore)
terminal
git rm -r --cached node_modules
git rm --cached .env
git check-ignore -v .env Fix the LF / CRLF line-ending warnings on Windows
terminal
git config --global core.autocrlf true
# in repo: .gitattributes
* text=autoVercel & Deploy · Deploy
Deploy a GitHub repo to Vercel for the first time
terminal
npm run build # test locally first
git push # triggers the deploy Preview vs production: where does my push go?
terminal
git push origin my-branch # preview deploy
git push origin main # production deployVercel & Deploy · Configure
Add and use environment variables
terminal
vercel link
vercel env add MY_KEY
vercel env pull .env.local Add a custom domain to my Vercel project
terminal
vercel domains add example.com
vercel domains inspect example.comVercel & Deploy · Roll back & debug
Roll back a bad deployment
terminal
vercel rollback <deployment-url>
git revert HEAD
git push A deployment failed: read the build log
terminal
npm ci
npm run build
vercel logs <deployment-url>Logging & Syslog · Basics
Facility, severity, ports and protocols (UDP, TCP, TLS)
terminal
UDP 514 classic syslog (fire and forget)
TCP 514 reliable (RFC 6587 framing)
TCP 6514 syslog over TLS (RFC 5425)
PRI = facility x 8 + severityLogging & Syslog · Install
Install a syslog server on Ubuntu (rsyslog)
terminal
sudo apt install -y rsyslog
sudo rsyslogd -N1
sudo systemctl restart rsyslog
sudo ss -lunp | grep 514 Install a syslog server on Windows
terminal
New-NetFirewallRule -DisplayName "Syslog UDP 514" -Direction Inbound -Protocol UDP -LocalPort 514 -RemoteAddress 192.168.1.1 -Action Allow
netstat -ano | findstr :514 Run the syslog server as a VMware VM (Workstation or ESXi)
terminal
sudo netplan try
sudo apt install -y open-vm-tools Add searchable dashboards with Graylog (Docker)
terminal
docker compose up -d
docker compose logs -f graylogLogging & Syslog · Connect sources
Send FortiGate logs to a syslog server
terminal
config log syslogd setting
set status enable
set server "192.168.1.10"
set mode udp
set port 514
end Send VMware ESXi logs to a syslog server
terminal
esxcli system syslog config set --loghost='udp://192.168.1.10:514'
esxcli system syslog reload
esxcli network firewall ruleset set --ruleset-id=syslog --enabled=true
esxcli network firewall refresh Forward a Linux server's logs to the syslog server
terminal
sudo tee /etc/rsyslog.d/90-forward.conf
sudo rsyslogd -N1
sudo systemctl restart rsyslogLogging & Syslog · Network & security
Open the right ports (Ubuntu, Windows, AWS)
terminal
sudo ufw allow from 192.168.1.1 to any port 514 proto udp
sudo ufw allow from 192.168.1.1 to any port 514 proto tcp
sudo ufw status numberedLogging & Syslog · Operate
Size the disk and set retention
terminal
GB/day = EPS x avg_bytes x 86400 / 1e9
total GB = GB/day x retention_days Fix time and timezone problems in logs
terminal
timedatectl
chronyc tracking
sudo timedatectl set-timezone UTCLogging & Syslog · Troubleshoot
No logs arriving: step-by-step checklist
terminal
sudo ss -lunp | grep 514
sudo tcpdump -ni any port 514
sudo ufw status
sudo rsyslogd -N1