Git & GitHub
/Beginner
git status
Definition
Displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git.
Explain Like I'm New
The most used command in Git. It's like asking Git: 'Hey, what's going on right now?' It tells you what branch you are on, and lists out exactly which files you have modified, added, or deleted.
Real World Example
You come back to your computer after a lunch break. You forgot what files you were editing. You type `git status` to instantly see your unsaved progress.
Common Use Cases
- •Checking project state before committing
- •Verifying files were staged correctly
Crucial Command Flags
| Flag / Option | Description |
|---|---|
| -s / --short | Give the output in an abbreviated, highly compact format. |
| -u | Show untracked files. |
Terminal Output
bash / terminal
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: index.html
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
Untracked files:
(use "git add <file>..." to include in what will be committed)
new-image.png
Interview Questions
basic
- What color does `git status` usually use to show files that are in the Staging Area?
intermediate
- What does it mean if a file is listed under 'Untracked files'?