GitHub 25 ๐ Cheatsheet
1. Authentication (gh)
gh auth login # Interactive login
gh auth login -s workflow # Login with workflow scope (needed to push .github/workflows)
gh auth status # Check auth status and scopes
gh auth refresh -s workflow # Add scope to existing token
export GH_TOKEN="ghp_xxx" # Non-interactive auth for CI/scripts
2. Repositories
gh repo create my-app --public --clone # Create and clone locally
gh repo view OWNER/REPO # View repository details
gh repo fork OWNER/REPO --clone # Fork and clone
git remote add upstream <url> # Track the original repo
3. Issues & Pull Requests
gh issue create --title "Bug" --label bug
gh issue list --label bug
gh pr create --fill # Create PR using commit messages
gh pr checks <number> # Check CI status before merging
gh pr merge <number> --squash --delete-branch
gh pr checkout <number> # Switch local branch to the PR
4. GitHub Actions (gh)
gh run list # List recent runs
gh run watch <run-id> # Watch a run in real time
gh run rerun <run-id> --failed # Rerun failed jobs only
gh run download <run-id> --name dist # Download artifacts
gh workflow run ci.yml --ref main -f env=prod # Manual trigger
5. Releases
gh release create v1.0.0 --generate-notes # Auto-generate notes
gh release create v1.0.0 --draft # Create as draft
gh release view # View latest release
6. Git: Commits, Tags, Remotes
git tag -a v1.0.0 -m "Release" # Annotated tag
git push origin v1.0.0 # Push tag
git remote -v # List remotes
git remote set-url origin <url> # Change remote URL
git push -u origin main # First push, set upstream
git pull --rebase origin main # Sync before pushing
7. Git: Merging Strategies
# Note: Performed via GitHub UI or gh pr merge, but conceptual Git equivalents:
git merge feature # Merge commit (preserves branch history)
git merge --squash feature # Squash and merge (flattens to 1 commit)
git rebase main # Rebase (linear history, rewrites hashes)
8. CODEOWNERS & Branch Protection
# .github/CODEOWNERS
* @core-team
/docs/ @tech-writers
/security/ @security-team
# Branch Protection Rules (Settings โ Branches)
[x] Require a pull request
[x] Require approvals (1 or more)
[x] Dismiss stale pull request approvals
[x] Require review from Code Owners
[x] Require status checks to pass
[x] Do not allow bypassing the above settings
9. Workflow Configuration (.github/workflows/ci.yml)
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch: # Manual trigger
permissions:
contents: read
packages: write # Needed for GHCR
security-events: write # Needed for CodeQL
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test
10. GitHub Packages (GHCR)
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
docker tag myapp:latest ghcr.io/USERNAME/myapp:latest
docker push ghcr.io/USERNAME/myapp:latest
docker pull ghcr.io/USERNAME/myapp:latest
11. Security & Dependabot
# Dependabot Alerts (Settings โ Security and analysis)
Enable Dependabot alerts
Enable Dependabot security updates
# .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
12. GitHub Pages & Custom Domains
# Settings โ Pages โ Deploy from branch
Branch: main, Folder: /docs
# Custom Domain
Add CNAME file to /docs folder
Configure DNS (CNAME to user.github.io or A records to GitHub IPs)
Enable "Enforce HTTPS" in Settings
13. .github Directory Layout
.github/
โโโ workflows/ # CI/CD pipelines
โโโ ISSUE_TEMPLATE/ # Issue forms and config
โโโ PULL_REQUEST_TEMPLATE.md
โโโ CODEOWNERS
โโโ dependabot.yml
โโโ copilot-instructions.md
โโโ secret_scanning.yml
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!