git status tells you where your files stand. It changes none of your files, so run it as often as you like, especially before a commit.
A clean repository
When nothing has changed since the last commit, you see something like this:
$ git status
On branch main
nothing to commit, working tree cleanYour branch may be called master instead. The exact wording differs a little between Git versions.
Three kinds of change
Git thinks in three places: the working tree (the files you edit), the staging area (what will go into the next commit, also called the index) and the commit history.
Suppose you edit app.py, stage a change to README.md, and create a new file todo.txt:
$ git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: app.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
todo.txt"Changes to be committed" are staged. "Changes not staged" are edits to files Git already tracks. "Untracked" files are ones Git has never been told about. The hints in brackets show what to type next. Older versions suggest git reset HEAD for unstaging.
The same file can appear in both of the first two lists. This happens when you stage it and then edit it again. The commit would contain the staged version, not your newest edit, until you run git add once more.
Short format
For a compact view, add -s:
$ git status -s
M README.md
M app.py
?? todo.txtThere are two status columns. The left one describes the staging area and the right one describes the working tree. M means modified, A means added, and ?? means untracked.
Hiding files you never want
Build output and local secrets can clutter the untracked list. Put their names or patterns in a file called .gitignore:
*.log
build/Git then stops listing matching untracked files. This has no effect on files that are already tracked.
See the git status documentation for all the codes.
Try it
In a practice repository, create two files. Stage one with git add, then edit that same file again. Run git status and then git status -s, and explain every line to yourself.
Check your understanding
git status
All 3 sections · no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.