ZSZainSpireLibrary
Cheat sheet · updated 13 Nov 2026

Git & GitHub cheat sheet for AI builders

Git keeps a timeline of your project on your computer. GitHub keeps that timeline online, so it's safe and shareable. If you build with Claude or any AI, these few ideas save you from losing work.

The one habit Every time something works, tell Claude: "commit this with a clear message and push". When a prompt breaks your app, you can always go back.

01First-time setup (once)

  1. Create a free account on github.com.
  2. Install Git from git-scm.com, then check it with git --version.
  3. Install the GitHub CLI (cli.github.com) and run gh auth login. Now Claude Code can push for you.
  4. In your project folder, ask Claude: "initialise git, make the first commit, create a private GitHub repo and push".

Never commit passwords or API keys. Ask Claude to add a .gitignore and keep secrets in a .env file that isn't pushed.

02The cheat sheet

IdeaCommandSay to Claude
Commit
A snapshot of every file, linked to the one before
git add -A
git commit -m "msg"
"Commit everything with a clear message"
Timeline / log
Your app's history, commit by commit
git log --oneline"Show me the last 10 commits in one line each"
Go back
Undo changes by returning to a working commit
git revert <id>"Go back to the last commit where the app worked, but don't delete history"
Push
Upload your timeline to GitHub
git push"Push my commits to GitHub"
Clone
Download a repo with its whole timeline
git clone <url>"Clone this repo and tell me how to run it"
Branch
A second timeline to try something safely
git switch -c new-feature"Create a branch called dark-mode and work there"
Merge
Bring a working branch back into main
git switch main
git merge new-feature
"It works, merge dark-mode into main"
Delete branch
Throw away an experiment
git branch -D new-feature"That didn't work, delete the dark-mode branch and go back to main"
Tag
Name a version you can return to
git tag v1
git push --tags
"Tag this version as v1 and push the tag"

03Good to know

Links Git: git-scm.com
GitHub CLI: cli.github.com
GitHub docs, Get started: docs.github.com