Bird
Raised Fist0
Gitdevops~20 mins

git status to see current state - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

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
Challenge - 5 Problems
🎖️
Git Status Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of git status after modifying a tracked file?
You have a tracked file named app.py. You edit it but do not stage the changes. What will git status show?
AOn branch main\nChanges not staged for commit:\n (use "git add <file>..." to update what will be committed)\n (use "git restore <file>..." to discard changes in working directory)\n\n\tmodified: app.py\n\nno changes added to commit (use "git add" and/or "git commit -a")
Bfatal: not a git repository (or any of the parent directories): .git
COn branch main\nnothing to commit, working tree clean
DOn branch main\nUntracked files:\n (use "git add <file>..." to include in what will be committed)\n\n\tapp.py\n\nnothing added to commit but untracked files present (use "git add" to track)
Attempts:
2 left
💡 Hint
Think about what happens when you change a file but don't stage it.
💻 Command Output
intermediate
2:00remaining
What does git status show after staging a new file?
You create a new file README.md and run git add README.md. What will git status display?
AOn branch main\nUntracked files:\n (use "git add <file>..." to include in what will be committed)\n\n\tREADME.md
BOn branch main\nnothing to commit, working tree clean
COn branch main\nChanges to be committed:\n (use "git restore --staged <file>..." to unstage)\n\n\tnew file: README.md
Dfatal: pathspec 'README.md' did not match any files
Attempts:
2 left
💡 Hint
What does staging a file do to its status?
Troubleshoot
advanced
2:00remaining
Why does git status show 'fatal: not a git repository'?
You run git status inside a folder but get the error: fatal: not a git repository (or any of the parent directories): .git. What is the most likely cause?
AYou have uncommitted changes in the repository.
BYou have staged files but not committed them yet.
CYour remote repository URL is incorrect.
DYou are not inside a folder initialized as a git repository (no .git folder present).
Attempts:
2 left
💡 Hint
Think about what makes a folder a git repository.
Best Practice
advanced
2:00remaining
Which git status output indicates a clean working directory ready for a new commit?
You want to confirm your working directory has no changes before starting new work. Which git status output shows this?
AOn branch main\nnothing to commit, working tree clean
BOn branch main\nChanges not staged for commit:\n modified: index.html
COn branch main\nChanges to be committed:\n new file: script.js
DOn branch main\nUntracked files:\n README.md
Attempts:
2 left
💡 Hint
Look for the message that says there are no changes.
🔀 Workflow
expert
3:00remaining
What sequence of git status outputs occurs when you modify, stage, and then unstage a file?
You modify app.js, stage it, then unstage it using git restore --staged app.js. What is the correct order of git status outputs after each step?
A3,2,1
B1,2,3
C1,3,2
D2,1,3
Attempts:
2 left
💡 Hint
Think about how staging and unstaging affect the file's status.

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

  1. Step 1: Understand the purpose of git status

    This command tells you which files are new, changed, or ready to be saved (staged).
  2. 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.
  3. Final Answer:

    The current state of files: new, modified, or staged changes -> Option A
  4. 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

  1. Step 1: Recall the exact command for checking file states

    The correct command is git status to see new, modified, or staged files.
  2. Step 2: Identify incorrect commands

    git check, git show status, and git state are not valid Git commands for this purpose.
  3. Final Answer:

    git status -> Option B
  4. 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

  1. Step 1: Interpret 'Changes not staged for commit'

    This means app.js has changes but is not yet added to the staging area.
  2. Step 2: Interpret 'Untracked files'

    test.txt is a new file Git does not track yet.
  3. Final Answer:

    app.js is modified but not staged; test.txt is new and untracked -> Option D
  4. 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

  1. Step 1: Understand normal git status behavior

    Normally, git status always shows some output, even if clean.
  2. 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.
  3. Final Answer:

    You are not inside a Git repository directory -> Option C
  4. 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

  1. Step 1: Use git status to check file states

    This shows which files are modified or staged before committing.
  2. Step 2: Stage changes and commit

    git add . stages all changes, then git commit -m 'message' saves them.
  3. Final Answer:

    git status -> git add . -> git commit -m 'message' -> Option A
  4. Quick Check:

    status -> add -> commit [OK]
Hint: Check status first, then add, then commit [OK]
Common Mistakes:
  • Committing before adding changes
  • Pushing before committing
  • Checking status after commit instead of before