0
0
Gitdevops~20 mins

Bisect for finding bug-introducing commits in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bisect Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Bisect Start and Marking Commits
You start a git bisect session with git bisect start. You mark commit abc123 as bad and commit def456 as good. What is the next step git expects you to do?
AManually check out the next commit git selects and mark it as good or bad
BReset the bisect session with <code>git bisect reset</code>
CMerge the good commit into the bad commit branch
DRun <code>git bisect run</code> immediately to automate testing
Attempts:
2 left
💡 Hint
Think about how git bisect narrows down the commit range step by step.
💻 Command Output
intermediate
2:00remaining
Bisect Command Output Interpretation
You run git bisect bad after testing a commit. Git outputs:
Bisecting: 3 revisions left to test after this (roughly 2 steps)
Next commit to test is 789abcde

What does this output mean?
AGit encountered an error and cannot continue bisecting
BGit found the bad commit at 789abcde and bisect is finished
CThere are 3 commits left to check, and git will take about 2 more steps to find the bad commit
DYou must reset bisect because the range is invalid
Attempts:
2 left
💡 Hint
Look at the number of revisions left and the next commit hash.
Troubleshoot
advanced
2:00remaining
Bisect Session Stuck on a Commit
During a bisect session, you test a commit but the build fails and you cannot determine if it is good or bad. What is the best way to proceed?
ASkip the commit using <code>git bisect skip</code> and continue
BMark the commit as bad to continue bisecting
CMark the commit as good to continue bisecting
DAbort the bisect session with <code>git bisect reset</code>
Attempts:
2 left
💡 Hint
Think about how to handle commits that cannot be tested.
🧠 Conceptual
advanced
2:00remaining
Understanding Bisect Algorithm Efficiency
Git bisect uses a binary search algorithm to find the bad commit. If you have 128 commits between good and bad, what is the maximum number of steps git bisect will take to find the bad commit?
A128 steps
B7 steps
C64 steps
D256 steps
Attempts:
2 left
💡 Hint
Binary search halves the search space each step.
Best Practice
expert
2:00remaining
Automating Bisect with a Test Script
You want to automate git bisect using git bisect run with a test script that exits 0 if the commit is good and 1 if bad. Which of the following scripts is correct for this purpose?
A
#!/bin/sh
make test; exit 0
B
#!/bin/sh
exit 0
C
#!/bin/sh
if make test; then exit 1; else exit 0; fi
D
#!/bin/sh
make test &amp;&amp; exit 0 || exit 1
Attempts:
2 left
💡 Hint
The script must exit 0 for good commits and non-zero for bad commits.