0
0
Gitdevops~20 mins

Working directory state in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Working Directory Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Identify the output of 'git status' after file modification
You have a Git repository. You modified a tracked file named app.py but have not staged the changes yet. What will be the output of git status?
Git
git status
A
On branch main
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)

	modified:   app.py
B
On branch main
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:   app.py

no changes added to commit (use "git add" and/or "git commit -a")
C
On branch main
nothing to commit, working tree clean
Dfatal: not a git repository (or any of the parent directories): .git
Attempts:
2 left
💡 Hint
Think about what happens when you modify a file but do not stage it.
🧠 Conceptual
intermediate
1:30remaining
Understanding the working directory vs staging area
Which statement correctly describes the difference between the working directory and the staging area in Git?
AThe working directory is where you edit files, and the staging area is where you prepare changes to be committed.
BThe working directory contains files as they are in the last commit, and the staging area holds files with uncommitted changes.
CThe staging area is a backup of the working directory, and the working directory is the repository history.
DThe working directory is a remote copy of the repository, and the staging area is the local repository.
Attempts:
2 left
💡 Hint
Think about where you make changes and where you mark changes for commit.
Troubleshoot
advanced
2:00remaining
Diagnosing untracked files after git add
You ran git add README.md but git status still shows README.md as untracked. What is the most likely cause?
AREADME.md is ignored by a .gitignore rule.
BThe file has been deleted from the working directory.
CYou have not committed the file yet, so it remains untracked.
DYou ran <code>git add</code> in a different directory than where README.md is located.
Attempts:
2 left
💡 Hint
Check if the file is excluded by Git rules.
🔀 Workflow
advanced
2:30remaining
Sequence to discard changes in working directory
You accidentally modified a file config.yaml and want to discard all changes, restoring it to the last committed state. Which sequence of commands achieves this?
A2,4,1,3
B1,4,2,3
C1
D4,2,3,1
Attempts:
2 left
💡 Hint
Think about the simplest way to discard unstaged changes.
Best Practice
expert
3:00remaining
Best practice to keep working directory clean in a team
In a team project, what is the best practice to ensure the working directory stays clean and avoids conflicts before starting new work?
AIgnore changes in the working directory and work directly on the remote repository.
BDelete the working directory and clone the repository fresh each time.
CAlways commit all changes immediately, even incomplete work.
DUse <code>git stash</code> to save unfinished changes before switching branches or pulling updates.
Attempts:
2 left
💡 Hint
Think about temporarily saving work without committing.