Repositories and the three states
Understand the idea
A repository is three places for the same files: the working tree, the index, and the commit history.
The idea
A on this platform is a stored history plus the labels that point into it. Creating one writes a row for your account. The address looks like /git/field-notes. Reload the page and the same commits are still there.
What changes
git status compares three places. The is what you just typed. The is the snapshot you have selected. HEAD is the last photo. A file can differ in any of those pairs, and status names which pair.
| Place | What it holds | How you read it |
|---|---|---|
| Working tree | Edits that are not staged yet | git diff |
| Index | The snapshot the next commit will store | git diff --staged |
| HEAD | The current commit | git show |
The command
Sign in, then use Create repository on this page. After it exists, run git status. Then write notes.txt hello, git add notes.txt, and git status again. The file moves from unstaged to staged. git commit -m "start notes" stores the index and the graph gains a node. Hashes here are short platform ids, not Git's SHA-1, and the reference lists every command this terminal actually runs.
The mistake
Check your graph
After the commit, main and HEAD sit on the new node. Reload. The same hash should still be on the graph, because the repository row kept the state.
Your repository
Create your first persisted repository here. git status reads those three states. The graph starts with the initial commit.
Step 1
Create the repository
Use the form above. That writes the repository for your account and starts main with an initial commit. If it already exists, go to the next step.
Step 2
See the three states
Status compares the working tree, the index, and the latest commit. Right now they match.
Step 3
Edit a file
In the editor, open README.md. If it is not listed, create it. Replace the text with: Field notes for the week
Step 4
Read the unstaged diff
The editor changed the working tree. Nothing is staged yet. The diff is that gap.
Step 5
Stage the file
git add copies README.md from the working tree into the index. The editor text is what gets staged.
Step 6
Read the staged diff
This is the snapshot the next commit will store.
Step 7
Commit
The commit stores the index and moves main.
Step 8
Confirm the history
Status should be clean. The log shows the new commit on the graph.
The editor edits the working tree. Start a repository and the files appear here.
Commit graph
No commits yet. git init creates the first one.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 100 XP. You can always revisit it.