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
Recall & Review
beginner
What is a tracked file in Git?
A tracked file is a file that Git knows about and is monitoring for changes. It has been added to the repository at some point, usually with git add, and is part of the version history.
Click to reveal answer
beginner
What does it mean when a file is untracked in Git?
An untracked file is a file in your working directory that Git does not know about yet. It has not been added to the repository, so Git does not monitor it until you tell it to track the file.
Click to reveal answer
beginner
How can you see which files are tracked or untracked in your Git repository?
You can run git status. It shows tracked files with changes and lists untracked files separately under "Untracked files".
Click to reveal answer
beginner
How do you start tracking an untracked file?
Use the command git add <filename>. This stages the file and tells Git to track it in the next commit.
Click to reveal answer
beginner
What happens if you modify a tracked file?
Git notices the change and marks the file as modified. You can then stage the changes with git add and commit them to save the new version.
Click to reveal answer
Which command shows untracked files in your Git repository?
Agit commit
Bgit clone
Cgit push
Dgit status
✗ Incorrect
git status lists untracked files under the "Untracked files" section.
What does it mean if a file is listed under "Untracked files" in git status?
AThe file is new and not yet added to Git
BThe file is deleted
CThe file is committed
DThe file is ignored by Git
✗ Incorrect
Untracked files are new files Git has not been told to track yet.
How do you start tracking a new file in Git?
Agit clone <filename>
Bgit commit <filename>
Cgit add <filename>
Dgit push <filename>
✗ Incorrect
git add stages a file to be tracked and committed.
If you modify a tracked file, what is the next step to save changes in Git?
Agit add <filename>
Bgit clone
Cgit status
Dgit init
✗ Incorrect
You stage changes with git add before committing.
Which of these files will Git not track by default?
ATracked files
BUntracked files not added
CFiles staged with git add
DCommitted files
✗ Incorrect
Untracked files are not tracked by Git until added.
Explain the difference between tracked and untracked files in Git.
Think about what Git knows and monitors in your project.
You got /4 concepts.
Describe the steps to start tracking a new file and save its changes in Git.
Consider the commands to add and commit files.
You got /3 concepts.
Practice
(1/5)
1. What does it mean when a file is untracked in Git?
easy
A. The file is already included in the last commit.
B. Git does not know about the file yet and it is not included in commits.
C. The file is ignored by Git due to .gitignore rules.
D. The file is staged and ready to be committed.
Solution
Step 1: Understand the meaning of untracked files
Untracked files are those that Git has not seen before and are not part of any commit.
Step 2: Compare with tracked files
Tracked files are known to Git and included in commits, unlike untracked files.
Final Answer:
Git does not know about the file yet and it is not included in commits. -> Option B
Quick Check:
Untracked = Not known to Git [OK]
Hint: Untracked means Git hasn't seen the file yet [OK]
Common Mistakes:
Confusing untracked with ignored files
Thinking untracked files are staged
Assuming untracked files are committed
2. Which Git command is used to start tracking an untracked file?
easy
A. git commit
B. git status
C. git push
D. git add
Solution
Step 1: Identify the command to track files
The git add command tells Git to start tracking a file by adding it to the staging area.
Step 2: Differentiate from other commands
git commit saves changes, git push sends commits to remote, and git status shows file states.
Final Answer:
git add -> Option D
Quick Check:
Start tracking = git add [OK]
Hint: Use git add to track new files [OK]
Common Mistakes:
Using git commit before adding files
Confusing git push with tracking
Thinking git status tracks files
3. Given the following Git status output:
Untracked files:
(use "git add <file>..." to include in what will be committed)
newfile.txt
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: trackedfile.txt
Which files are currently tracked by Git?
medium
A. trackedfile.txt only
B. Both newfile.txt and trackedfile.txt
C. newfile.txt only
D. Neither file is tracked
Solution
Step 1: Analyze the status output sections
The "Untracked files" section lists files Git does not track yet, here newfile.txt. The "Changes to be committed" section lists tracked files staged for commit, here trackedfile.txt.
Step 2: Determine tracked files
Only trackedfile.txt is tracked because it is staged. newfile.txt is untracked.
Final Answer:
trackedfile.txt only -> Option A
Quick Check:
Tracked files = staged or committed files [OK]
Hint: Tracked files appear under 'Changes to be committed' [OK]
Common Mistakes:
Assuming untracked files are tracked
Confusing staged with untracked
Ignoring the status section labels
4. You ran git add newfile.txt but git status still shows newfile.txt as untracked. What is the most likely reason?
medium
A. The file is listed in .gitignore and ignored by Git.
B. You forgot to commit after adding the file.
C. You used the wrong filename in the add command.
D. Git does not track files with certain extensions.
Solution
Step 1: Understand why git add might not track a file
If a file is ignored by Git due to .gitignore rules, git add will not track it and it remains untracked.
Step 2: Eliminate other reasons
Committing is not required to track a file; wrong filename would cause an error; Git tracks all extensions unless ignored.
Final Answer:
The file is listed in .gitignore and ignored by Git. -> Option A
Quick Check:
Ignored files stay untracked despite git add [OK]
Hint: Check .gitignore if git add doesn't track file [OK]
Common Mistakes:
Thinking commit is needed to track
Ignoring .gitignore rules
Assuming Git restricts file types
5. You have a folder with files: file1.txt (tracked, modified), file2.txt (untracked), and file3.log (untracked). Your .gitignore contains *.log. You want to commit file2.txt but not the changes in file1.txt or file3.log. What is the correct sequence of commands?
hard
A. git add file3.log; git commit -m "Add file3"
B. git add .; git commit -m "Add all files"
C. git add file2.txt; git commit -m "Add file2"
D. git commit -a -m "Add file2 and file3"
Solution
Step 1: Understand .gitignore effect
The pattern *.log in .gitignore causes file3.log to be ignored and untracked, so it won't be added by git add ..
Step 2: Choose commands to add only file2.txt
Using git add file2.txt adds only that file without staging changes to tracked file1.txt. Then commit saves it. git add file3.log is ignored. git add . would add file2.txt AND stage changes to file1.txt. Using git commit -a only commits tracked files, so untracked file2.txt won't be included.