Three tools to keep handy: the jargon translator, the command cheat sheet, and the panic page for scary messages.
Plain idea on the left, the word everyone actually says on the right.
| The idea | What it's called |
|---|---|
| The whole photo album (project + its entire history) | repository ("repo") |
| A save point: photo of everything + a note | commit |
A save point's receipt number, like f30f6b7 | SHA / hash |
| The shopping basket of changes for your next save | staging area / "the index" |
| A bookmark on a line of work | branch |
| The "you are here" bookmark | HEAD |
| The default/official branch | main (older repos: "master") |
| A cloud copy of your album (usually on GitHub) | remote, nicknamed origin |
| Download a whole repo for the first time | clone |
| Upload my new save points | push |
| Download theirs, just to look | fetch |
| Download theirs and blend into mine | pull |
| Slide the bookmark forward (history never forked) | fast-forward |
| Tie two forked lines together with a new save point | merge / merge commit |
| "Both sides edited the same spot: you decide" | merge conflict |
| Undo a shared commit by adding its opposite | revert |
| Redo your last (unshared) commit | amend |
| "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 file | README.md |
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
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
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
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
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
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.Scary-looking messages, and what they actually mean.
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.)
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 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.
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.
You're in a folder git doesn't manage. cd into your project folder, or start tracking this one with git init.
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.
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.