Not a folder of copies
Most people picture version control as a stack of backups. Git is closer to a small database: every time you commit, it stores a snapshot of the whole project, gives it an id, and remembers which snapshot came before.
Because a snapshot has an id, and the id is computed from the content, two identical files are stored once, and a commit cannot be altered without its id changing. That is the entire security model and most of the speed.
$ git log --oneline
832dbe3 (HEAD -> main) add the fitting notes
23fd5c3 first draft of the price list
Three places, and every command moves between them
Almost every confusion in git is a question about which of these three a command touches. git add copies from the working tree into the index. git commit turns the index into a permanent snapshot. git restore copies backwards. Keep the three columns in your head and the rest follows.
| Place | What it is | How things get there |
|---|---|---|
| Working tree | the files you are editing right now | you edit them |
| Index (staging area) | what the next commit will contain | git add |
| Repository | the snapshots that are kept forever | git commit |
Why the middle one exists
Most tools have two places: what you have and what you saved. Git's third one lets you decide what goes in this commit — you fixed a bug and also renamed a variable in another file, and those are two different commits. You stage one, commit it, stage the other, commit that.
This is what makes a git history readable a year later, and it is the single habit that separates a useful history from a list of "update".
Setting it up, once
git config --global user.name "Ulvi Shabanbayli"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git --version
The panel on the right runs a small git written for this course. It is not a recording: it builds real git objects and hashes them with SHA-1, so the ids you see are the ids the real git prints for the same content. What it does not have is a network, a file system, or the parts of git the lessons never use — and it says so plainly when you ask for one of them.
The vocabulary, in one place
| Word | Means |
|---|---|
| repository (repo) | the project, plus all of its history |
| commit | one snapshot, with a message, an author and a parent |
| branch | a moving name for one commit — nothing more |
| HEAD | where you are: usually a branch name |
| remote | another copy of the repository, usually on a server |
| clone / fetch / push | copy one down · get their new commits · send yours |