Skip to content

H.3 — Git essentials

Status: drafted · Time: 3 min · Audience: everyone Outcome: Everyday Git commands plus the four recovery moves that handle most situations.

Printable card · Companion to W.3 — Git as save-points. The everyday commands plus the four recovery moves.


CommandWhat it does
git statusShows what is changed, staged, and untracked. The “where am I” of Git.
git add <file>Stages a file for the next commit
git add .Stages everything in the current directory
git commit -m "<message>"Creates a commit with a message
git pushSends commits to the remote
git pullPulls remote changes into your branch
git logShows the commit history. Add --oneline for a compact view.
git diffShows what is changed but not staged
git diff --stagedShows what is staged but not committed
git branchLists local branches; the current one is marked
git checkout -b <name>Creates a new branch and switches to it
git checkout <name>Switches to an existing branch
SituationThe move
You changed a file but want the original backgit checkout -- <file> (discards local changes; cannot be undone)
You committed something you should not havegit reset HEAD~1 (undoes the last commit but keeps the changes)
You pushed to the wrong branchTalk to someone before you act. The fix usually involves git revert, which is safe. Avoid git push --force unless you know exactly what you are doing.
You are completely lost and want a clean slategit stash (saves your changes for later); then you can sync with the remote without losing work

Git tracks save-points (commits) of your work. A repository is a tree of those save-points. Branches are named pointers into the tree. The everyday commands move between save-points; the recovery moves get you out of trouble.

Two things to remember:

  1. Once a commit is pushed to a shared branch, it is public. Treat it as permanent.
  2. git status is free. Run it any time you are unsure of state. The output tells you exactly what is happening.

A good commit message is short, present-tense, and imperative.

GoodLess good
Add weekly status report skillAdded a skill for generating weekly status reports
Fix off-by-one in paginationFixed bug
Document the RFC review cadence in C.3Updated docs

The first line is what shows up in git log --oneline. Make it useful.


If git pull produces a merge conflict and you do not know what to do, stop typing. Take a screenshot or copy the output, and ask in #ai-help. Bad merge resolutions are how repositories get into states that are hard to recover from.

If you see “DETACHED HEAD” in git status, you can usually recover with git checkout <branch-name>. If you are unsure, ask.


Not a full Git reference. Git has thousands of options. This card covers what you actually need for White Belt and Yellow Belt.

Not a substitute for the chapter. W.3 covers the mental model of save-points, the relationship between local and remote, and the patterns that compound.

Not a manual for advanced workflows. Rebasing, cherry-picking, interactive rebase, and submodules all exist; they are not in this card because they are not in White or Yellow Belt.


Remember: git status is free. Run it whenever you are unsure.

Up to: ↑ Appendix H · Companion: W.3 — Git as save-points