GitHub with the panic v1

The sequel to GitHub without the panic (the prequel). That one got you through the door. This one is for when Claude Code is sitting in your project folder doing the git work, and you would like to know what you are saying yes to.

The whole guide in one line: let Claude type the commands, but you read the diff before any commit and you decide when anything leaves your laptop. Everything else is detail, and almost everything is undoable.

In short

  1. Claude Code is an assistant in your terminal. It reads your files and runs commands, but it asks before it does anything that changes things. Each prompt is a yes/no from you.
  2. A commit is a saved snapshot. Ask Claude to commit, and ask to see what changed first.
  3. Never overwrite the original. Save fixes as a new, versioned copy. Git then keeps both.
  4. Private by default. Make something public only as a deliberate, scanned, sanitised copy.
  5. Secrets, client files and student data never get committed. Not even once, not even "temporarily".
  6. Pushing is the moment it leaves your machine. Say "commit but don't push" until you have looked.
  7. Panicked? Stop, and ask Claude to explain before it fixes anything. Two flags are dangerous: --hard and --force.

The running example

Throughout, we follow a fictional tutor and a small team of content creators. They make practice-test slide decks. Their loop looks like this:

  1. Download a deck (.pptx) into a project folder.
  2. Claude Code reviews it and writes Review.md and Fixes Log.md.
  3. Fixes go into a versioned copy of the deck. The original is never touched.
  4. Commit, then push to a private repo called my-deck-reviews.
  5. Later, a sanitised public toolkit is shared with other teachers.

Every name, file and folder in this guide is made up. Swap in your own: your-name, my-deck-reviews, and so on.

1What Claude Code is, and what it is asking you

Claude Code is an AI assistant that lives in a terminal window, inside one folder. Unlike a chat window, it can do things: read the files in that folder, edit them, and run commands such as git.

That is also why it asks permission. Before it edits a file or runs a command, it stops and shows you what it wants to do. You choose.

You seeWhat it means
Read a fileLooking only. Safe. Usually allowed without asking.
Edit / write a fileIt will change something in your folder. Check the file name. Git can undo it if you have committed.
Run git status, git diff, git logLooking only. Safe.
Run git add, git commitSaves a snapshot on your laptop. Reversible. Fine.
Run git pushSends your work to GitHub. Slow down and read.
Run gh repo createCreates something on GitHub. Check public vs private.
Anything with --hard, --force, or rmCan destroy work. Say no, then ask why it needs that.
The habit: read the one line it is about to run. If you can't tell what it does, answer no and type: "Explain what that command does and what could go wrong, in plain English. Don't run it yet."

Many people choose "allow this kind of command for the session" for the harmless read-only ones, so they are not prompted fifty times. Do that for git status and git diff. Do not do it for push.

2Starting a project: your first commit

A repo starts life as an ordinary folder. git init turns it into a folder with a memory. A commit is one saved snapshot of it.

1
Make a folder, e.g. my-deck-reviews, and drop the first deck into it.
2
Open Claude Code in that folder and type the prompt below.
3
Approve the commands one by one, reading each.

You type:

"This folder is a new project. Set it up as a git repo, then show me what would go into the first commit before you commit anything."

A sensible Claude does roughly this, asking before each step:

git init # turns the folder into a repo git status # lists the files git can see git add . # stages them (picks them for the snapshot) git commit -m "Add first deck" # takes the snapshot
Watch for git add . — the dot means "everything". Before you approve, ask: "What files is that adding?" Section 8 is why.

Nothing has gone online. All of this lives on your laptop, in a hidden folder called .git. Don't delete it; it is the memory.

3Commits, good messages, and reading the diff

A diff is the list of what changed since the last snapshot: lines in red were removed, lines in green were added. It is the single most useful thing you can read as a non-programmer, because it answers "what is about to be saved?"

You type:

"Show me the diff of what you changed, in plain English, and wait for my OK before committing."

Claude runs git diff, then summarises. For the deck example it might say: "Three files changed: Review.md is new (a 40-line review), Fixes Log.md is new (six entries), and the v2 deck is a new file. The original deck is unchanged." That last sentence is what you are checking for.

What a good commit message looks like

A message is a note to your future self. Short first line, saying what and why.

PoorGood
updateReview Grade 7 acids deck; log six fixes
fixesAdd v2 of acids deck with Q3 answer key corrected
stuffMove scratch notes out of the repo

You can simply ask: "Write the commit message in the style of the existing ones." It can read git log to match.

The rule for your team's decks: never overwrite the original. Fixes go into a new file with a version tag in its name, e.g. Acids Deck (reviewed v2).pptx. Git can already restore old versions, but a clear file name saves a conversation when someone opens the folder.

4Branches

A branch is a separate line of work. The main line is usually called main. Think of a branch as a photocopy of the project that you can scribble on freely; if you like the result you merge it back, if you don't you throw the copy away.

Use one whenever a change is bigger than a quick fix, or when several people are working at once. In the example, each creator takes their own branch per deck: review-acids-g7, review-metals-g7.

You type:

"Make a new branch called review-acids-g7 and switch to it. Do the review work there, not on main."

git switch -c review-acids-g7 # create and move to the branch git branch # which branch am I on? (starred) git switch main # go back

Lost? Ask: "Which branch am I on, and is there any work not saved?"

5Pull requests

A pull request (PR) is a polite way of saying: "I did some work on a branch. Please look at it before it joins main." It is a page on GitHub where the changes are shown as a diff, and where others can comment.

Useful even if you work alone: it gives you one more look at the diff before anything changes on main.

You type:

"Open a pull request from this branch into main. Write the description for a teacher, not an engineer: what changed and which slides I should check."

Claude uses the GitHub command-line tool, gh:

gh pr create --title "Review: G7 acids deck" --body "..." # opens the PR gh pr view --web # opens it in your browser

Open the link, read the "Files changed" tab, and press the green Merge button yourself when you are happy. Merging is your decision, not Claude's.

6Signing in: gh auth login

Before gh can do anything on GitHub, it needs to know who you are. You do this once per computer.

1
In a normal terminal (not inside Claude's chat) type gh auth login.
2
Choose GitHub.com, then HTTPS, then Login with a web browser.
3
It shows a short one-time code. Your browser opens; paste the code and approve.
4
Check it worked: gh auth status should say you are logged in.
Do this part yourself. Sign-in is your identity. Don't paste passwords or tokens into a chat with Claude, and if it ever asks you to, stop. The browser flow above never needs you to.

7Private vs public, and sharing a sanitised copy

PrivatePublic
Only you and people you inviteAnyone on the internet, forever (search engines, copies)
Right for working drafts, client decks, anything unfinishedRight for finished, generic, share-worthy material

The team starts private. Their working repo, my-deck-reviews, contains real review history, half-fixed decks and notes about who asked for what. None of that should be public.

But the method is worth sharing: the review checklist, the prompts, the folder layout. So they make a sanitised public copy, a new, separate project. This is not a switch from private to public. Flipping the visibility of the old repo would publish its whole history, including everything deleted months ago.

The recipe

1
Copy only the shareable files into a new folder, e.g. deck-review-toolkit. Not the whole project.
2
Fresh history. Run git init in the new folder. Do not copy the .git folder. The public repo starts with one clean commit, and old messages and file names stay behind.
3
Neutral identity. Every commit is stamped with a name and email. Set a project-only one so your real details aren't printed on a public page:
git config user.name "deck-review-toolkit contributors" git config user.email "noreply@example.com"
4
Run a privacy scan before the first commit. Search every file for things that should not be there, case-insensitively: your email address, your school or company name, your username, local folder paths, links to private documents, and anything that looks like a key.
grep -rniE "@your-email-provider|your-school|your-username|your-home-folder|your-private-doc-link|your-token-prefix" .
5
Read the results with Claude. Fix every hit, then scan again until it comes back empty.
6
Commit, but don't publish yet. Look at the file list one more time yourself. Then, and only then, create the public repo.

You type:

"I want a public copy of the shareable parts of this project in a new folder called deck-review-toolkit. Fresh git history, a neutral git identity (noreply@example.com), and run a case-insensitive grep for my name, email, school, local paths and any tokens before you commit. Show me any hits. Do not create a GitHub repo or push."

Remember: anything that was ever public may already be copied. Deleting a repo later doesn't un-ring that bell. A scan is cheap; an apology to a student's parent is not.

8.gitignore and secrets

Git saves everything it can see. A file named .gitignore lists things it must pretend it can't see. Claude can write it for you.

Three categories that must never be committed:

You type:

"Create a .gitignore for this project. Ignore .env files, anything in a folder called private/, student-marks spreadsheets, and temporary files. Then tell me whether any of those are already committed."

# .gitignore .env private/ *.xlsx ~$* .DS_Store
If a secret was committed, ignoring it later is too late. It is still in the history. Treat the token as stolen: revoke it on the website that issued it and make a new one, then ask Claude how to remove it from history. Don't push in the meantime.

Good question to ask before every first push: "Is there anything in this commit that I wouldn't want a stranger to read?"

9Worktrees: a parallel copy

A worktree is a second copy of the project in another folder, linked to the same repo and sitting on a different branch. It lets you or Claude try something risky without disturbing the folder you are working in.

In the example, the tutor keeps teaching from the main folder while Claude reviews a new deck in a worktree. Nothing in the main folder moves under their feet.

You type:

"Do this review in a separate worktree on its own branch, so my main folder isn't touched. Tell me where it is when you're done."

git worktree add ../review-copy review-acids-g7 # make the parallel copy git worktree list # see all copies git worktree remove ../review-copy # tidy up when merged

Claude Code can do this itself if you ask. If something goes wrong in the copy, delete it. The main folder is fine.

10"I panicked": undo recipes

Good news: once something is committed, it is very hard to truly lose. The first move is always the same: stop, breathe, and ask Claude to look before it touches anything.

You type:

"Something went wrong. Don't change anything yet. Run git status and git log, and explain in plain English what state we're in."

SituationRecipeRisk
Typo in the last commit message, or forgot one filegit commit --amendSafe if not pushed yet
A commit that is already shared turned out wronggit revert <commit> (adds a new commit that cancels it)Safe. History stays honest.
I messed up one file, want it back as it wasgit restore <file>Discards unsaved changes to that file
I want to un-commit but keep my workgit reset --soft HEAD~1Safe. Work stays staged.
"I lost a commit!" / "I reset too far"git reflog, find it, then git switch -c rescue <id>Safe. This is the safety net.

The safety net: reflog

Git quietly keeps a diary of every place you have been, called the reflog. Even a "deleted" commit is usually still there for weeks.

You type:

"I think I lost the commit where I fixed Q3. Look in the reflog, show me the candidates, and put the right one on a new branch called rescue. Don't touch main."

Two things to say no to, every time, until you understand them:
git reset --hard — throws away uncommitted work permanently. The reflog cannot bring back something that was never committed.
git push --force — overwrites what is on GitHub with your version. It can erase teammates' work.
If Claude proposes either, answer: "Why that one? Is there a safer way? What exactly would I lose?"
Cheap insurance: before any risky move, ask "Make a backup branch of where we are right now." It costs nothing and gives you a way back.

11Pushing

Push means "send my commits to GitHub". Until now everything has lived on your laptop. Push is the moment other people (or the internet) can see it.

The first time, you need a remote, the address of the repo on GitHub. For the private working repo:

You type:

"Create a private GitHub repo called my-deck-reviews from this folder and push the main branch. Confirm it is private before you run it."

gh repo create my-deck-reviews --private --source=. --push # create + push, privately git push # later pushes

Before you approve a push, check three things on that one line: where it is going, which branch, and that the word --force is not in it. On a first push, also check that --private is there.

Pushing again is fine and routine. Each push just adds your newest commits.

12Asking Claude to hold off

The best control you have is one sentence. Claude does what you say; you only need to say it early.

Phrases worth keeping handy:

For the team, the full loop becomes: download the deck, Claude reviews it and writes the two notes, fixes go into a versioned copy, stop and read the diff, commit, stop and say push. Later, build the sanitised toolkit the same way: scan, commit, stop and read the file list, and only then ask for the public repo.

If you have a CLAUDE.md file in the folder (a note Claude reads at the start of every session), put the standing rules there once: "Never overwrite originals. Never push without asking. Never commit anything in private/."

13Words that stop mattering once you know them

repoone project folder with its memory
commitone saved snapshot, with a note
diffwhat changed since the last snapshot
stage / addchoose which changes go in the next snapshot
brancha separate line of work
mergebring a branch's work back into main
pull request"please look at this before it joins main"
remotethe copy of the repo that lives on GitHub
pushsend commits to GitHub
worktreea second folder on another branch, same repo
refloggit's diary of everywhere you have been; the undo safety net
.gitignorethe list of things git must pretend not to see
ghGitHub's command-line helper, used by Claude for PRs and repo creation
--hard / --forcethe two flags to say no to
Not sure what Claude is about to do? Ask it. "Explain this like I'm a teacher who has never opened a terminal." It's patient, and the question is free.