What is git status used for?
git status shows the current state of the working directory and the index (staging area): which files are modified, which are ready to commit, and which are not yet tracked by Git.
What exactly git status shows
1. Modified files
Files that:
- are already tracked by Git
- were modified after the last commit
- have not yet been added to the staging area
text
modified: src/app.js2. Staged files
Files that:
- were added with
git add - will be included in the next commit
text
new file: src/index.js3. Untracked files
Files that:
- exist in the project
- are not under Git's control
text
Untracked files:
config.env4. Clean repository state
If there are no changes:
text
nothing to commit, working tree cleanWhy git status is used in practice
- To check exactly what will be committed
- To avoid accidentally committing unwanted files
- To see which files were forgotten (
git add) - To check before
git commitandgit push - To quickly diagnose the state of the repository
Commonly used options
bash
git status # full information
git status -s # short formatExample of short output:
text
M src/app.js
?? .envShort answer for an interview
git statusis used to view the current state of the repository: modified, staged, and untracked files.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.