0
0
Gitdevops~20 mins

Garbage collection with git gc - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Garbage Collector Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does git gc do?
Which of the following best describes the purpose of the git gc command?
AIt clones a remote repository to your local machine.
BIt deletes all branches except the current one.
CIt resets the repository to the last commit, discarding all changes.
DIt cleans up unnecessary files and optimizes the local repository by compressing objects.
Attempts:
2 left
💡 Hint
Think about how Git manages storage and what cleanup might mean.
query_result
intermediate
2:00remaining
Output of git gc --dry-run
What is the expected output when running git gc --dry-run in a repository?
AShows the current branch name only.
BDeletes all untracked files immediately.
CLists the files and objects that would be cleaned or compressed without making changes.
DDisplays an error saying the command is invalid.
Attempts:
2 left
💡 Hint
The --dry-run option usually means no changes are made.
📝 Syntax
advanced
2:00remaining
Identify the correct git gc command to aggressively optimize
Which command runs git gc with aggressive optimization to compress objects more thoroughly?
Agit gc --aggressive
Bgit gc --force-aggressive
Cgit gc --deep-clean
Dgit gc --compress-all
Attempts:
2 left
💡 Hint
Look for the official flag that increases compression effort.
🔧 Debug
advanced
2:00remaining
Why does git gc fail with 'unable to create temporary file' error?
You run git gc and get the error: unable to create temporary file. What is the most likely cause?
AThe disk is full or the user lacks write permissions in the repository directory.
BThe repository has no commits yet.
CThe remote repository is unreachable.
DThe current branch is not checked out.
Attempts:
2 left
💡 Hint
Temporary files need space and permission to be created.
optimization
expert
3:00remaining
How to automate git gc for large repositories?
For a large repository with many objects, which approach best automates running git gc without impacting developer workflow?
ARun <code>git gc --aggressive</code> manually every time a commit is made.
BSchedule <code>git gc --auto</code> to run periodically in the background during low activity times.
CDisable garbage collection entirely to avoid any delays.
DRun <code>git gc</code> only after pushing to the remote repository.
Attempts:
2 left
💡 Hint
Think about balancing optimization and developer experience.