Related
Initialize Repository
Create an empty Git repository in a directory to start version controlling your project
Clone Repository
Clone an existing Git repository from a remote server to your local machine, creating a complete copy with full history
Reset Changes
Reset current HEAD to the specified state
Command
git statusExplanation
The git status command provides a comprehensive overview of your repository's current state, showing which files have been modified, staged for commit, or are untracked. This is one of the most frequently used Git commands as it helps you understand what changes exist in your working directory before committing. The command displays files in different states: modified (changed but not staged), staged (added to index for next commit), untracked (new files not yet tracked by Git), and sometimes deleted or renamed files. The default output shows detailed information including branch name, upstream tracking status, and a list of all changed files. Using the -s or --short flag provides a compact view perfect for quick checks. Understanding git status output is fundamental to effective Git workflows, as it helps you decide when to stage files, commit changes, or clean up untracked files. Regular use of this command helps prevent accidental commits of unwanted changes and ensures you're aware of your repository state at all times.
Common Use Cases
- •Checking which files have been modified before committing
- •Verifying repository state before switching branches
- •Reviewing staged changes before committing
- •Identifying untracked files that should be added
- •Quick status check during development workflow
Best Practices
- ✓Run git status frequently to stay aware of repository state
- ✓Use git status before switching branches to avoid losing work
- ✓Use -s flag for quick checks in scripts or when you know the changes
- ✓Check status after resolving merge conflicts before committing
- ✓Review untracked files regularly to add important ones to version control
Common Mistakes to Avoid
- ⚠Not checking status before committing and missing changes
- ⚠Confusing staged vs unstaged files
- ⚠Forgetting to check status after merge conflicts
- ⚠Not understanding what "Changes to be committed" means
Troubleshooting
Problem: Status shows files as modified but they look unchanged
Solution: Check line endings (CRLF vs LF) with git config core.autocrlf or file permissions with git config core.fileMode.
Problem: Untracked files not showing up
Solution: Verify they're not in .gitignore. Check .gitignore rules with git check-ignore -v <file>.
Examples
Show full status
git statusShort status format
git status -sMachine-readable status format
git status --porcelainShow ignored files as well
git status --ignoredMore
Manage Tags
Create, list, and manage tags for marking specific commits in your repository
Clean Untracked Files
Remove untracked files and directories from your working tree to restore a clean workspace
Manage Worktrees
Manage multiple working trees linked to a single Git repository for simultaneous development across branches