0
0
Gitdevops~20 mins

Sparse checkout for partial repos in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sparse Checkout Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Sparse checkout initialization output
You run these commands in a new Git repository:

git init
git remote add origin https://example.com/repo.git
git config core.sparseCheckout true
echo "docs/" > .git/info/sparse-checkout
git pull origin main

What will be the output or result of the last command?
ANo files are checked out; the working directory remains empty.
BThe entire repository is downloaded and checked out locally.
CGit throws an error because sparse checkout is not supported in this sequence.
DOnly the 'docs/' folder and its contents are downloaded and checked out locally.
Attempts:
2 left
💡 Hint
Sparse checkout allows you to check out only parts of the repo you want.
🧠 Conceptual
intermediate
1:30remaining
Understanding sparse-checkout file format
Which of the following lines in the .git/info/sparse-checkout file will include all files inside the 'src' directory and its subdirectories?
Asrc/*
Bsrc/
C/src
Dsrc
Attempts:
2 left
💡 Hint
Trailing slash means directory and all contents.
🔀 Workflow
advanced
2:30remaining
Steps to enable sparse checkout on an existing repo
You have cloned a large repository fully. Now you want to enable sparse checkout to keep only the 'config/' folder locally. Which sequence of commands correctly achieves this?
Agit config core.sparseCheckout true<br>echo "config/" > .git/info/sparse-checkout<br>git read-tree -mu HEAD
Becho "config/" > .git/info/sparse-checkout<br>git config core.sparseCheckout true<br>git checkout HEAD
Cgit sparse-checkout init<br>git sparse-checkout set config/
Dgit config core.sparseCheckout true<br>git checkout config/
Attempts:
2 left
💡 Hint
You must enable sparse checkout, set the patterns, then update the working tree.
Troubleshoot
advanced
2:00remaining
Sparse checkout not working as expected
You enabled sparse checkout and set the sparse-checkout file to include 'app/'. But after pulling, you still see all files checked out. What is the most likely cause?
AThe core.sparseCheckout setting is not enabled (false).
BThe remote URL is incorrect.
CThe branch name is misspelled in the pull command.
DThe sparse-checkout file has incorrect file permissions.
Attempts:
2 left
💡 Hint
Sparse checkout must be explicitly enabled in Git config.
Best Practice
expert
3:00remaining
Efficient sparse checkout with Git's built-in commands
Which command sequence uses Git's built-in sparse-checkout commands to initialize sparse checkout and set it to only the 'frontend/' and 'backend/' folders?
Agit config core.sparseCheckout true<br>echo "frontend/\nbackend/" > .git/info/sparse-checkout<br>git read-tree -mu HEAD
Bgit sparse-checkout init<br>git sparse-checkout add frontend backend
Cgit sparse-checkout init --cone<br>git sparse-checkout set frontend backend
Dgit sparse-checkout enable<br>git sparse-checkout include frontend backend
Attempts:
2 left
💡 Hint
Use the new sparse-checkout commands with cone mode for simplicity.