plainweb

4 minute read

Git basics for AI coders

Five Git commands cover almost everything a new AI coder needs: git status to see what changed, git add -A and git commit -m to save a snapshot, git push to send it to GitHub, git restore to undo uncommitted changes, and git log to see history. Commit before and after every AI session so any mistake is one step from undone.

The five commands

CommandWhat it does
git statusShows what changed since the last save
git add -A then git commit -m "message"Saves a snapshot
git pushSends your snapshots to GitHub
git restore .Throws away changes since the last snapshot
git log --onelineLists your snapshots

First time setup

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git init

Branches, briefly

A branch is a safe copy to try something on. git switch -c try-redesign makes one; git switch main goes back. If the experiment fails, just delete the branch.

Related

Next