Reference ๐Ÿ“–

Three tools to keep handy: the jargon translator, the command cheat sheet, and the panic page for scary messages.

AJargon translator

Plain idea on the left, the word everyone actually says on the right.

The ideaWhat it's called
The whole photo album (project + its entire history)repository ("repo")
A save point: photo of everything + a notecommit
A save point's receipt number, like f30f6b7SHA / hash
The shopping basket of changes for your next savestaging area / "the index"
A bookmark on a line of workbranch
The "you are here" bookmarkHEAD
The default/official branchmain (older repos: "master")
A cloud copy of your album (usually on GitHub)remote, nicknamed origin
Download a whole repo for the first timeclone
Upload my new save pointspush
Download theirs, just to lookfetch
Download theirs and blend into minepull
Slide the bookmark forward (history never forked)fast-forward
Tie two forked lines together with a new save pointmerge / merge commit
"Both sides edited the same spot: you decide"merge conflict
Undo a shared commit by adding its oppositerevert
Redo your last (unshared) commitamend
"Here's my branch: review it, then merge it" (GitHub)pull request (PR)
A to-do/bug ticket attached to a repo (GitHub)issue
Your own copy of someone else's repo (GitHub)fork
The list of files git should ignore.gitignore
The repo's front-page instructions fileREADME.md

BCommand cheat sheet

๐Ÿ‘€ Look around (always safe)

git status          # what's changed? what's staged? THE command to run when unsure
git log --oneline   # the photo album, newest first
git diff            # changes not yet in the basket, line by line (after git add: git diff --staged)
git branch          # list bookmarks; * marks where you are

๐Ÿ’พ Save

git add file.txt     # put one file in the basket
git add -A           # put everything in the basket
git commit -m "note" # take the photo, with your note

๐Ÿ”– Branch

git switch -c my-idea  # new bookmark + move to it
git switch main        # jump back to main
git merge my-idea      # bring my-idea's work into the branch you're on

โ˜๏ธ Sync with GitHub

git clone URL        # first-time download of a repo
git push             # upload your commits
git pull             # download + blend in the latest
git fetch            # download only: look before you blend

โ†ฉ๏ธ Undo (from gentle to sharp)

git restore file.txt          # discard unsaved edits to one file โš  gone for good
git commit --amend            # redo last commit (only if NOT pushed yet)
git revert <sha>              # safe undo of a shared commit: adds the opposite
git reflog                    # the safety net: where HEAD has been lately
โš ๏ธ Sharp tools live here: git reset --hard and git push --force can genuinely destroy work. The rule of thumb as a beginner: if a command needs --hard or --force, stop and ask someone (or an AI) to double-check the plan first.

CThe panic page ๐Ÿšจ

Scary-looking messages, and what they actually mean.

"CONFLICT (content): Merge conflict in โ€ฆ"

Not an error. A question. Two versions of the same lines exist and git wants you to pick. Open the file, look for the <<<<<<< markers, keep what you want, delete the marker lines, then git add the file and git commit. (Lesson 7 walks through it.)

"! [rejected] โ€ฆ failed to push some refs"

GitHub has save points you haven't downloaded yet, and git refuses to overwrite anyone's work. Run git pull first (blend in their work), then git push again.

"You are in 'detached HEAD' state"

You jumped to an old photo directly, so your "you are here" marker isn't on any bookmark. Looking around is fine! If you want to keep changes you make here, put a bookmark down: git switch -c rescue-branch. To just go back: git switch main.

"Your local changes โ€ฆ would be overwritten by merge"

You have unsaved edits and the incoming work touches the same files. Commit your edits first (git add -A && git commit -m "wip"), then pull again.

"fatal: not a git repository"

You're in a folder git doesn't manage. cd into your project folder, or start tracking this one with git init.

"I think I lost my work!"

If you ever committed it, it's almost certainly still there. git reflog lists every place you've recently been, even "deleted" ones. Find the entry from before things went wrong, then git switch -c rescue <sha>. Uncommitted work is the only kind that's truly fragile: which is the best argument for committing often.

๐Ÿงญ When in doubt, the order of operations is: 1) git status: read what it says, it usually tells you the fix. 2) Breathe: committed work is almost unlosable. 3) Avoid --force and --hard until you're sure. 4) Ask: showing someone your git status output is the fastest path to unstuck.