Challenge - 5 Problems
Git Add Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What files are staged after running this command?
Given a directory with files:
What files will be staged after running:
- src/app.js
- src/utils.js
- test/app.test.js
- README.md
What files will be staged after running:
git add src/*.jsAttempts:
2 left
💡 Hint
The pattern matches files only in the specified directory, not subdirectories.
✗ Incorrect
The pattern 'src/*.js' matches all .js files directly inside the 'src' directory only. It does not include files in subdirectories like 'test/'.
💻 Command Output
intermediate2:00remaining
What is the effect of this git add command?
Assuming the current directory contains:
What files will be staged after:
- docs/intro.md
- docs/setup.md
- docs/images/logo.png
What files will be staged after:
git add docs/*.mdAttempts:
2 left
💡 Hint
The pattern '*.md' matches markdown files only in the specified directory.
✗ Incorrect
The pattern 'docs/*.md' matches all markdown files directly inside 'docs' but not files in subdirectories like 'docs/images/'.
❓ Configuration
advanced2:00remaining
How to stage all files recursively in a directory?
You want to stage all files inside the 'src' directory and all its subdirectories. Which command achieves this?
Attempts:
2 left
💡 Hint
Adding a directory stages all files inside it recursively.
✗ Incorrect
Using 'git add src/' stages all files inside 'src' and its subdirectories recursively. Patterns like 'src/*' only match files directly inside 'src'.
❓ Troubleshoot
advanced2:00remaining
Why does this git add command not stage files in subdirectories?
You run:
But files in 'logs/2024/' are not staged. Why?
git add logs/*.logBut files in 'logs/2024/' are not staged. Why?
Attempts:
2 left
💡 Hint
Patterns without recursive wildcards do not match files in subfolders.
✗ Incorrect
The pattern '*.log' matches only files directly inside 'logs'. To include subdirectories, you must add the directory or use recursive patterns.
🔀 Workflow
expert3:00remaining
Which command stages only .js files in all subdirectories of 'src'?
You want to stage all .js files inside 'src' and any nested folders. Which command works correctly?
Attempts:
2 left
💡 Hint
Use double star '**' for recursive matching in supported shells.
✗ Incorrect
The pattern 'src/**/*.js' matches all .js files recursively in 'src' and subfolders. Other options either match only top-level files or all files.