0
0
Gitdevops~20 mins

Untracked vs tracked files in Git - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Untracked vs Tracked Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify tracked and untracked files
You run git status and see some files listed under 'Untracked files' and others under 'Changes not staged for commit'. What does this mean about these files?
AFiles under 'Untracked files' are deleted; files under 'Changes not staged for commit' are new files.
BFiles under 'Untracked files' are committed; files under 'Changes not staged for commit' are untracked.
CFiles under 'Untracked files' are staged for commit; files under 'Changes not staged for commit' are ignored by Git.
DFiles under 'Untracked files' are new and not added to Git; files under 'Changes not staged for commit' are tracked but modified.
Attempts:
2 left
💡 Hint
Think about whether Git knows about the file or not.
💻 Command Output
intermediate
2:00remaining
Output of git status with untracked files
What is the output of git status after creating a new file notes.txt but before adding it?
Git
$ touch notes.txt
$ git status
A
On branch main
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	notes.txt

nothing added to commit but untracked files present (use "git add" to track)
B
On branch main
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)

	new file:   notes.txt
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
The file is new and not added yet.
🔀 Workflow
advanced
2:00remaining
Correct workflow to track a new file
You created a new file app.log but want Git to track it. Which sequence of commands correctly tracks and commits this file?
A
git push origin main
 git add app.log
B
git add app.log
 git commit -m "Add app.log"
C
git commit -m "Add app.log"
 git add app.log
D
git rm app.log
 git commit -m "Remove app.log"
Attempts:
2 left
💡 Hint
Think about the order: add first, then commit.
Troubleshoot
advanced
2:00remaining
Why is a new file not showing as untracked?
You created a new file secret.txt but git status does not show it as untracked. What is the most likely reason?
AThe file is listed in .gitignore, so Git ignores it.
BThe file is already committed and tracked.
CThe file has syntax errors.
DGit is not installed on your system.
Attempts:
2 left
💡 Hint
Check if Git is told to ignore the file.
Best Practice
expert
2:00remaining
Best practice for handling large untracked log files
Your project generates large log files that should not be tracked by Git. What is the best practice to handle these files?
ARename the log files to .txt to make Git track them.
BCommit the log files regularly to keep history of logs.
CAdd the log files to .gitignore to prevent tracking and accidental commits.
DDelete the log files manually before every commit.
Attempts:
2 left
💡 Hint
Think about avoiding clutter and large files in Git.