Git status command shows the state of files in your project. It shows files in the staged area, files not yet staged, and files not tracked by Git.
It also shows which branch you use at the moment and if you have changes to commit. You can run it many times to see updates after you add or reset files.
Understand the git status Command
Git status command shows what files Git will commit and what files Git does not track yet. It does not change the files but only shows their state. It helps you know what to do before you commit.
You can use this command often to see what files are ready for the next commit.
Here is the command:
This command shows your current branch name at the top. It then shows two lists. The first list has files in the staged area. The second list has files that you changed but did not stage yet. At the end, it shows files Git does not track at all.
Staged files are ready for commit. Unstaged files are changed but not yet added. Untracked files are new files outside Git.
The Difference Between git status Short and Long output
Git status has two types of output. The long output is the default one you see when you run git status with no flags.
It shows branch, staged files, unstaged files, and untracked files in full detail.
The short output shows less detail in a compact form. You get it with the -s or --short flag. It shows a two-letter code near each file.
The first letter shows staged status and the second letter shows unstaged status. This is faster to read when you work on many files.
Here is the command:
You can use the long output when you want full detail about file states. You can use the short output when you only need quick info on file changes.
Examples
Show status of files in a new repository:
This example runs git status in a new repository. It shows the current branch name. It shows that no commits exist yet.
Stage a file and see the change:
git add index.html
git status
This example stages a file with git add. Then it runs git status. The output shows the file index.html in the staged area, ready for commit. It also shows other files still not staged.
Use short output for quick checks:
This example uses the short output. It shows each file with a two-letter code. It is useful when you have many files and need a quick view of changes.
Mix staged and unstaged files:
git add app.js
git status
This example stages app.js but leaves style.css unstaged. Git status shows app.js in the staged area. It shows style.css as changed but not yet staged. You can now decide to stage or discard it.
Wrapping Up
You learned how git status shows file states and how you can use both long and short output to track changes.
Here is a quick recap:
- Run git status to see the branch and file states, use git status -s for a compact view, and stage or unstage files based on what the command shows.
FAQs
What is the use of git status command in Git?
git status command shows the current state of the working directory.
It displays:
- Untracked files that are not staged
- Changes staged for commit
- Changes not staged yet
Example:
git status
How do you check staged and unstaged changes with git status?
Run
git status in your repository.
Output explains both:
- Changes to be committed → Staged changes
- Changes not staged for commit → Modified files not staged
Example:
git add file1.txt
git status
What is the difference between git status and git status -s?
git status gives a detailed description.
git status -s or git status --short gives a short view.
- M → Modified
- A → Added
- ?? → Untracked
Example:
git status -s
How to fix untracked files shown in git status?
You can add or ignore untracked files.
- Track files with
git add filename
- Ignore files by adding them in
.gitignore
Check again with:
git status
Similar Reads