Process Flow - Clean vs dirty working directory
Start: Working Directory
Check for changes?
Clean
Ready for
This flow shows how Git checks your working directory for changes. If no changes, it's clean; if changes exist, it's dirty.
git status # Shows if working directory is clean or dirty
| Step | Command | Working Directory State | Git Output Summary | Next Action |
|---|---|---|---|---|
| 1 | git status | No changes | "working tree clean" | Ready for next commit |
| 2 | touch file.txt | New untracked file | "Untracked files:" list shown | Add or ignore file |
| 3 | git add file.txt | File staged | "Changes to be committed:" list shown | Commit or unstage |
| 4 | echo 'change' > file.txt | Modified staged file | "Changes not staged for commit:" list shown | Add changes or discard |
| 5 | git commit -m 'Add file.txt' | No changes | "working tree clean" | Ready for next commit |
| Variable | Start | After Step 2 | After Step 3 | After Step 4 | After Step 5 |
|---|---|---|---|---|---|
| Working Directory | Clean | Dirty (untracked file) | Dirty (file staged) | Dirty (file modified) | Clean |
| Staging Area | Empty | Empty | file.txt staged | file.txt staged but modified | Empty |
Clean vs Dirty Working Directory in Git: - Clean: No changes or all changes committed. - Dirty: Untracked, modified, or staged changes exist. - git status shows state: 'working tree clean' means clean. - Use git add to stage changes. - Modify after staging requires re-adding to update staging.