Bird
Raised Fist0
Gitdevops~10 mins

Sparse checkout for partial repos in Git - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to enable sparse checkout in your Git repository.

Git
git config core.[1] true
Drag options to blanks, or click blank then click option'
AsparseCheckout
Bsparsecheckout
Csparse-checkout
Dsparse_checkout
Attempts:
3 left
💡 Hint
Common Mistakes
Using hyphens ('sparse-checkout').
Using all lowercase without camelCase.
Using underscores ('sparse_checkout').
2fill in blank
medium

Complete the command to initialize sparse checkout.

Git
git sparse-checkout [1]
Drag options to blanks, or click blank then click option'
Asetup
Benable
Cstart
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'enable' instead of 'init'.
Using 'start' which is not a valid git sparse-checkout command.
Using 'setup' which is not recognized.
3fill in blank
hard

Fix the error in the command to set sparse checkout paths by completing the blank.

Git
echo "[1]" > .git/info/sparse-checkout
Drag options to blanks, or click blank then click option'
A/docs/
Bdocs
C/docs
Ddocs/
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the leading slash.
Omitting the trailing slash.
Using relative paths without slashes.
4fill in blank
hard

Fill both blanks to complete the command that updates the working directory to match the sparse checkout settings.

Git
git [1] -u [2]
Drag options to blanks, or click blank then click option'
Aread-tree
Bcheckout
C-m
D-f
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'checkout' instead of 'read-tree'.
Using '-f' instead of '-m'.
Omitting flags.
5fill in blank
hard

Fill all three blanks to create a sparse checkout config file that includes the 'src' directory, excludes 'tests', and includes 'README.md'.

Git
/[1]/
![2]/
[3]
Drag options to blanks, or click blank then click option'
Asrc
Btests
CREADME.md
Ddocs
Attempts:
3 left
💡 Hint
Common Mistakes
Not using '!' to exclude tests.
Missing slashes for directories.
Including 'docs' instead of 'README.md'.

Practice

(1/5)
1. What is the main purpose of using git sparse-checkout?
easy
A. To merge two branches automatically
B. To clone a repository faster by skipping all files
C. To delete files from the repository permanently
D. To download only specific parts of a repository you need

Solution

  1. Step 1: Understand sparse checkout concept

    Sparse checkout allows you to work with only parts of a repo instead of the whole repo.
  2. Step 2: Identify the main purpose

    This helps save space and time by downloading only needed folders or files.
  3. Final Answer:

    To download only specific parts of a repository you need -> Option D
  4. Quick Check:

    Sparse checkout = partial repo download [OK]
Hint: Sparse checkout means partial repo download only [OK]
Common Mistakes:
  • Thinking it deletes files from the repo
  • Confusing with branch merging
  • Assuming it skips all files
2. Which command correctly initializes sparse checkout with cone mode?
easy
A. git sparse-checkout start --cone
B. git sparse-checkout init --cone
C. git sparse-checkout enable --cone
D. git sparse-checkout create --cone

Solution

  1. Step 1: Recall the correct initialization command

    The official command to start sparse checkout in cone mode is git sparse-checkout init --cone.
  2. Step 2: Verify other options

    Other commands like start, enable, or create are not valid git sparse-checkout commands.
  3. Final Answer:

    git sparse-checkout init --cone -> Option B
  4. Quick Check:

    Init with --cone = git sparse-checkout init --cone [OK]
Hint: Use 'init' with '--cone' to start sparse checkout [OK]
Common Mistakes:
  • Using 'start' instead of 'init'
  • Forgetting the '--cone' flag
  • Using invalid verbs like 'enable' or 'create'
3. After running git sparse-checkout set docs src, which folders will be present in your working directory?
medium
A. No folders, only files at root
B. All folders except 'docs' and 'src'
C. Only the 'docs' and 'src' folders
D. All folders in the repository

Solution

  1. Step 1: Understand the effect of 'git sparse-checkout set'

    This command sets which folders to include in the working directory.
  2. Step 2: Analyze the given folders

    Setting 'docs' and 'src' means only these two folders will be checked out and visible.
  3. Final Answer:

    Only the 'docs' and 'src' folders -> Option C
  4. Quick Check:

    Set folders = only those folders appear [OK]
Hint: Set folders to include with 'git sparse-checkout set' [OK]
Common Mistakes:
  • Assuming all folders remain
  • Thinking it excludes specified folders
  • Expecting files outside these folders to appear
4. You ran git sparse-checkout set src but still see all folders. What is the likely mistake?
medium
A. You forgot to run git sparse-checkout init --cone first
B. You used the wrong folder name in the set command
C. You need to delete the .git folder to apply changes
D. Sparse checkout does not work on folders, only files

Solution

  1. Step 1: Check sparse checkout initialization

    Before setting folders, you must initialize sparse checkout with git sparse-checkout init --cone.
  2. Step 2: Understand why all folders appear

    If not initialized, sparse checkout settings are ignored, so all folders remain visible.
  3. Final Answer:

    You forgot to run git sparse-checkout init --cone first -> Option A
  4. Quick Check:

    Init missing = no sparse effect [OK]
Hint: Always init sparse checkout before setting folders [OK]
Common Mistakes:
  • Skipping initialization step
  • Deleting .git folder unnecessarily
  • Believing sparse checkout works only on files
5. You want to work only on the frontend and backend/api folders in a large repo. Which sequence of commands correctly sets this up?
hard
A. git sparse-checkout init --cone git sparse-checkout set frontend backend/api
B. git sparse-checkout set frontend backend/api git sparse-checkout init --cone
C. git sparse-checkout init git sparse-checkout set frontend backend/api
D. git sparse-checkout init --cone git sparse-checkout add frontend backend/api

Solution

  1. Step 1: Initialize sparse checkout with cone mode

    Use git sparse-checkout init --cone to enable sparse checkout in cone mode.
  2. Step 2: Set the folders to include

    Use git sparse-checkout set frontend backend/api to specify the folders you want.
  3. Step 3: Verify command order and syntax

    Initialization must come before setting folders; 'add' is not a valid command.
  4. Final Answer:

    git sparse-checkout init --cone git sparse-checkout set frontend backend/api -> Option A
  5. Quick Check:

    Init then set folders = correct sequence [OK]
Hint: Init sparse checkout first, then set folders [OK]
Common Mistakes:
  • Setting folders before initialization
  • Using 'add' instead of 'set'
  • Omitting the '--cone' flag during init
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard