Your daily Git workflow
Check the repository status
Use git status before and after every important operation to see what Git knows about your files.
8 minute lesson
git status is the command that keeps you oriented.
Run it before and after an operation:
git status
Git compares three states: HEAD, the staging area, and the working tree.
It reports changes in useful groups:
- Changes to be committed are in the staging area.
- Changes not staged for commit exist only in the working tree.
- Untracked files are in the working tree but not in
HEADor the index.
Status also shows the current branch. When a branch tracks a remote branch, it can show whether your local reference is ahead or behind the last fetched remote-tracking reference.
Notice that git status does not show every changed line. Use git diff for that.
My advice is to run git status often. It is the safest way to stay oriented.
You can use the shorter format once you understand the full one:
git status --short
Exercise: create one untracked file, modify one tracked file, and stage a third file. Run both status formats and identify where each change currently lives.
Lesson completed