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.
Table of Content
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:
git statusThis 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:
git status
git status -sYou 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:
git statusThis 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 statusThis 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:
git status -sThis 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 statusThis 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?
- Untracked files that are not staged
- Changes staged for commit
- Changes not staged yet
git status How do you check staged and unstaged changes with git status?
git status in your repository.
Output explains both:
- Changes to be committed → Staged changes
- Changes not staged for commit → Modified files not staged
git add file1.txt
git status What is the difference between git status and git status -s?
- M → Modified
- A → Added
- ?? → Untracked
git status -s How to fix untracked files shown in git status?
- Track files with
git add filename - Ignore files by adding them in
.gitignore
git status
Similar Reads
The Git add command places new or changed files into the staging area so you can prepare them for the…
If you're diving into coding, your introduction to Git and GitHub will happen in no time. Git's your personal time…
You sometimes need to remove old or unneeded branches locally in Git. You might want to keep your project clean…
The switch operation in Git will make it easier. Designed to simplify the process for developers, it's safer and more…
You can use the Git config command to set user data and control Git behavior. It saves preferences for projects…
The purpose of the Git Push command is to upload local repository changes to a remote repository. Pushing your committed…
If you've worked on any coding project, you would know this frustrating wall where Git simply refuses to pull the…
One of the tools we need for software development is a Version Control System. It tracks code changes, making a…
You can use Git to show all branches or use branch-related commands to list branches and their status. This helps…
When you work on a project with friends, one writes the intro, one adds pictures, and others handle different parts.…