git/status

Check Repository Status

Display the current state of your working directory and staging area, showing which files are modified, staged, or untracked

git
status
repository
working directory
staging
changes

Command

git status

Explanation

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 status

Short status format

git status -s

Machine-readable status format

git status --porcelain

Show ignored files as well

git status --ignored