← Git from Scratch
Lesson 4 of 17 · 10 XP
git status: three states of a file
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
git status is git's most frequently used command. It shows what's going on:
On branch main
Changes to be committed: ← in the index, will go into the next commit
modified: a.txt
Changes not staged for commit: ← changed, but NOT added to the index
modified: b.txt
Untracked files: ← new files git doesn't know about yet
c.txt
The index lets you make tidy commits. For example, you fixed a bug and at the same time started a new feature. You can commit just the fix and leave the feature for later:
git add fix.py
git commit -m "Fix login"
If you added something to the index by mistake: git restore --staged file removes it from the index (the changes themselves stay).
Task. Two files have been changed in the repository, a.txt and b.txt (look at git status). Commit only a.txt with the message update a, and leave the changes in b.txt uncommitted.
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.