Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Using git status to see current state
📖 Scenario: You are working on a project and want to check what files have changed, which files are staged, and the current branch you are on.
🎯 Goal: Learn how to use the git status command to see the current state of your git repository.
📋 What You'll Learn
Have a git repository initialized
Make some changes to files
Use git status to check the current state
💡 Why This Matters
🌍 Real World
Developers use <code>git status</code> daily to understand what changes are staged, unstaged, or untracked before committing code.
💼 Career
Knowing how to check the git repository state is essential for version control and collaboration in software development jobs.
Progress0 / 4 steps
1
Initialize a git repository
Run the command git init to create a new git repository in your current folder.
Git
Hint
This command sets up a new git repository in your current folder.
2
Create a new file and add some content
Create a file named example.txt and add the text Hello Git inside it.
Git
Hint
You can use echo "Hello Git" > example.txt to create the file with content.
3
Check the current git status
Run the command git status to see the current state of your repository including untracked files.
Git
Hint
This command shows which files are untracked, modified, or staged.
4
View the output of git status
Observe the output of git status which should show example.txt as an untracked file.
Git
Hint
The output lists untracked files like example.txt under 'Untracked files:'
Practice
(1/5)
1. What does the git status command show you in a Git project?
easy
A. The current state of files: new, modified, or staged changes
B. The history of all commits in the project
C. The list of remote repositories connected
D. The size of the Git repository on disk
Solution
Step 1: Understand the purpose of git status
This command tells you which files are new, changed, or ready to be saved (staged).
Step 2: Compare with other Git commands
Commands like git log show commit history, not file states. git remote shows remotes, and size info is not shown by git status.
Final Answer:
The current state of files: new, modified, or staged changes -> Option A
Quick Check:
git status -> new/modified/staged [OK]
Hint: Remember: git status shows file changes [OK]
Common Mistakes:
Confusing git status with git log
Thinking it shows remote repository info
Expecting it to show repository size
2. Which of the following is the correct syntax to check the current state of your Git working directory?
easy
A. git state
B. git status
C. git show status
D. git check
Solution
Step 1: Recall the exact command for checking file states
The correct command is git status to see new, modified, or staged files.
Step 2: Identify incorrect commands
git check, git show status, and git state are not valid Git commands for this purpose.
Final Answer:
git status -> Option B
Quick Check:
git status = correct syntax [OK]
Hint: Use exactly git status to check file changes [OK]
Common Mistakes:
Adding extra words like 'show' or 'state'
Using non-existent commands
Misspelling 'status'
3. You run git status and see this output:
On branch main
Changes not staged for commit:
modified: app.js
Untracked files:
test.txt
What does this output tell you?
medium
A. Both files are committed and clean
B. app.js is staged and test.txt is committed
C. app.js is deleted; test.txt is staged
D. app.js is modified but not staged; test.txt is new and untracked
Solution
Step 1: Interpret 'Changes not staged for commit'
This means app.js has changes but is not yet added to the staging area.
Step 2: Interpret 'Untracked files'
test.txt is a new file Git does not track yet.
Final Answer:
app.js is modified but not staged; test.txt is new and untracked -> Option D
Quick Check:
not staged + untracked -> modified/new [OK]
Hint: Look for 'not staged' and 'untracked' labels in output [OK]
Common Mistakes:
Assuming modified files are staged
Thinking untracked files are committed
Confusing deleted files with modified
4. You ran git status but it shows:
fatal: not a git repository (or any of the parent directories): .git
What is the most likely reason?
medium
A. You have no internet connection
B. Your Git installation is corrupted
C. You are not inside a Git repository directory
D. You have no changes to commit
Solution
Step 1: Understand normal git status behavior
Normally, git status always shows some output, even if clean.
Step 2: Identify why this fatal error occurs
This error means you are not inside a Git repository folder, so Git cannot find the project.
Final Answer:
You are not inside a Git repository directory -> Option C
Quick Check:
fatal not repo -> not inside dir [OK]
Hint: Check if you are inside a Git folder before running commands [OK]
Common Mistakes:
Assuming no output means no changes
Blaming internet connection
Thinking Git is broken without checking repo
5. You want to check if any files are staged or modified before committing. Which sequence of commands will help you see the current state and then save your changes?
hard
A. git status -> git add . -> git commit -m 'message'
B. git commit -m 'message' -> git status -> git add .
C. git add . -> git commit -m 'message' -> git status
D. git push -> git status -> git commit -m 'message'
Solution
Step 1: Use git status to check file states
This shows which files are modified or staged before committing.
Step 2: Stage changes and commit
git add . stages all changes, then git commit -m 'message' saves them.
Final Answer:
git status -> git add . -> git commit -m 'message' -> Option A
Quick Check:
status -> add -> commit [OK]
Hint: Check status first, then add, then commit [OK]