How to Use git status: Check Your Git Repository State
Use the
git status command to see the current state of your Git repository. It shows which files are staged, unstaged, or untracked, and the branch you are on.Syntax
The basic syntax of git status is simple and has no required options. You can add options to customize the output.
git status: Shows the current status of your working directory and staging area.git status -s: Shows a short, concise status output.git status -b: Shows branch information along with status.
bash
git status git status -s git status -b
Example
This example shows how git status displays the state of files in your repository. It tells you which files are new, modified, or staged for commit.
bash
$ git status On branch main Your branch is up to date with 'origin/main'. 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: example.txt Untracked files: (use "git add <file>..." to include in what will be committed) newfile.txt no changes added to commit (use "git add" and/or "git commit -a")
Output
On branch main
Your branch is up to date with 'origin/main'.
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: example.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
newfile.txt
no changes added to commit (use "git add" and/or "git commit -a")
Common Pitfalls
Beginners often expect git status to show committed changes or remote updates, but it only shows local changes. Another mistake is ignoring untracked files that need to be added before committing.
Also, forgetting to stage files with git add means changes won't be included in the next commit even if git status shows them as modified.
bash
$ git status Changes not staged for commit: modified: file.txt # Wrong: committing without staging $ git commit -m "Update file" On branch main No changes added to commit # Right: stage before commit $ git add file.txt $ git commit -m "Update file"
Quick Reference
| Command | Description |
|---|---|
| git status | Show full status of working directory and staging area |
| git status -s | Show short status with symbols for changes |
| git status -b | Show branch info with status |
| git add | Stage file changes for commit |
| git commit -m "msg" | Commit staged changes with message |
Key Takeaways
Use
git status to see which files are changed, staged, or untracked.Always stage files with
git add before committing changes.git status shows local changes, not remote repository updates.Use
git status -s for a concise view of changes.Check your branch name and status before committing.