git status
Description:
Display the state of the working directory and staging area. Shows which files are modified, staged, untracked, or deleted.
Syntax:
bash
git status
git status -s
git status --shortExamples:
bash
# Full status output
git status
# Short format (condensed output)
git status -s
# Show branch and tracking info
git status -sbDetailed Explanation:
- Three states: Files can be untracked, modified (unstaged), or staged
- Branch info: Shows current branch and commits ahead/behind remote
- Safe command: This only reads information; it never changes anything
- Helpful hints: Provides suggestions for next steps (e.g., how to stage or unstage files)
Common Errors:
fatal: not a git repository→ Solution: You're not in a Git repository; rungit initorcdinto one- No errors typically occur with
git status– it's a read-only command
Pro Tips:
- Use
git status -sfor a cleaner, more compact view - Run
git statusfrequently to understand your repository state - Output legend:
??= untracked,M= modified,A= added,D= deleted git statusis your friend – use it before and after most Git commands
Related Commands:
git add– Stage changes shown in statusgit diff– See detailed changesgit log– View commit historygit commit– Commit staged changes