git status

Basic Snapshotting

Show the state of your working files and staging area


The 'git status' command shows which files you changed, which changes are staged for the next commit, and which files Git does not track yet. It never changes anything, so it is safe to run at any time — run it before every git add and git commit. It also tells you which branch you are on and, with a remote, how far you are ahead or behind.

Synopsis

git status [<options>] [--] [<pathspec>...]
[ ] optional| or<arg> placeholder... repeatable--flag option

Options

Click any option to expand

Beginner (2)

Give the output in the short format: two status letters per file (staging area, then working tree).

RecommendedCompact everyday view: two status letters per file

Example

git status -s

Show the branch and tracking info, even in the short format.

RecommendedAdds the branch and ahead/behind counts to the short format

Example

git status -sb

Intermediate (1)

Give the output in a stable, easy-to-parse format for scripts. It stays the same across Git versions and user settings.

When neededStable machine-readable format for scripts

Example

git status --porcelain

Choosing the Right Option

Short format codes

The two columns of git status -s

CommandMeaning
?? fileUntracked: Git does not know the file
M fileModified, not staged
M fileModified and staged
MM fileStaged, then modified again
A fileNew file, staged
D fileDeleted, not staged

Examples

Full status

git status

Lists staged changes, unstaged changes and untracked files, with hints.


Short format

git status -s

One line per file with a two-letter code.


Short with branch

git status -sb

Short format plus the branch and its ahead/behind counts.

Workflow Examples

1
git status

See what changed

2
git add app.js

Stage the file you want

3
git status

Check it is under "Changes to be committed"

4
git commit -m "Add to cart"

Commit

Troubleshooting

A file does not appear in git status

Cause: It is listed in .gitignore, or it has not changed

Check with git check-ignore -v <file>; unchanged tracked files are not listed

git status is slow in a big repository

Cause: Git scans every file of the working tree

Limit it to a folder: git status src/

Tips & Pitfalls

Best Practices

  • ✓Run git status before git add and before git commit.
  • ✓Read the hints: git status prints the command to undo each state.
  • ✓Use git status -sb for a compact view that still shows the branch.

Common Mistakes

  • ✗Committing without checking git status first, and recording files you did not mean to.
  • ✗Thinking an untracked file will be committed — it has to be added first.
  • ✗Reading " M" and "M " as the same thing: the column says whether the change is staged.

FAQ

A:

No. It only reads your files, the staging area and the last commit.

A:

Your files, the staging area and the last commit are identical: there is nothing to commit.

A:

You staged it, then edited it again. The staged version is what the next commit will record.