← Back to Git Course | Chapter 2: Basic Commands | Lesson 5 of 18

Git status Command

git status is like a teacher asking 'what is the situation right now?'. It tells you which files changed, which are ready to be saved, and which Git does not know about yet.
Syntax
bash
git status
git status -s

What is git status?

git status is Git's core diagnostic command -- run it whenever you're unsure what state your project is in, and it will list every file that's untracked, staged, or modified since the last commit, all in one readable summary.

Example: What is git status?

bash
git status

Reading Untracked Status

Files you've just created inside the project folder show up as Untracked -- Git has noticed them exist but is deliberately ignoring their contents until you explicitly git add them, so accidental files never sneak into history.

Example: Reading Untracked Status

bash
echo "new content" > newfile.txt
git status

Reading Staged Status

Files listed under 'Changes to be committed' are sitting in the staging area, meaning their current state will be captured exactly as-is the next time you run git commit -- this is the section to check before committing to confirm you're saving what you meant to.

Example: Reading Staged Status

bash
git add newfile.txt
git status

Reading Modified Status

Files under 'Changes not staged for commit' are ones Git already tracks that you've since modified -- the staged version and the working-directory version now differ, and you'll need to git add again to update what's staged.

Example: Reading Modified Status

bash
echo "more text" >> tracked.txt
git status

Shorthand Status Check

For a large project with many changed files, the full git status output can be overwhelming -- git status -s (or --short) compresses each file to a single line with a two-letter status code, making it much faster to scan.

Example: Shorthand Status Check

bash
git status -s
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Reading git status as showing committed history, when it shows only the current state of untracked, modified and staged files.
  2. Not noticing the two lists 'Changes to be committed' and 'Changes not staged for commit', so a modified file is assumed staged when it is not.
  3. Ignoring the hint text Git prints, such as use "git restore --staged <file>", that tells you exactly how to undo a step.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.