git status is the command used to check the current state of your repository. It tells you exactly what Git sees at this very moment: what branch you are on, which files are modified, which files are staged for the next commit, and which files are completely untracked.
git status is arguably the most important command in Git. It is your eyes and ears. Whenever you are confused, whenever a command fails, or whenever you come back to a project after a coffee break, you should run git status. It acts as a safety check to ensure you know exactly what you are about to save.
git statusWhen you run git status, Git will output information categorized into three main sections:
These are brand new files that you just created. Git says, "I see these files exist, but I am not tracking their history yet."
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
These are files that Git is already tracking, and you have made changes to them, but you haven't moved them to the Staging Area yet.
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: styles.css
These are files that have been successfully added to the Staging Area using git add. They are fully prepared and waiting for you to run git commit.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: index.html
modified: styles.css
If you just want a quick overview without all the explanatory text, you can use the "short" flag:
git status -sThis prints a compact list:
M styles.css (Modified)
?? index.html (Untracked)
A app.js (Added to staging)
- Not reading the hints: Beginners often ignore the text output of
git status. Read it carefully! Git actively tells you exactly what commands to run next. For example, it will tell you to usegit restoreto undo a mistake, orgit addto stage a file. - Committing blindly: Never run
git commitwithout runninggit statusfirst to verify exactly what files you are saving. You might accidentally commit a massive video file or a.envpassword file.
git statusshows the current state of your files.- It is a safe, read-only command. You can run it 100 times a day without breaking anything.
- Shows Untracked (new), Modified (changed), and Staged (ready) files.
- Always run this before running
git addorgit commit.