Find out how to use git bisect to identify broken commits on GitHub. Follow our step-by-step guide to test, troubleshoot, and fix app issues efficiently.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
Step 1: Clone the repository
git clone https://github.com/your-username/your-repo.git
cd your-repo
Step 2: Ensure you’re on the correct branch
git branch -a
git checkout main
git pull origin main
Step 3: Install dependencies and build the app
# example for a Node.js app
npm install
npm run build
npm start
Step 4: Run your test suite manually
# example using Jest for JavaScript
npm test
# or for Python projects
pytest
Step 5: Use git bisect to pinpoint the bad commit
git bisect start
git bisect bad # mark the current commit as bad
git bisect good v1.2.3 # replace v1.2.3 with a known good tag or commit
Step 6: Test each bisect step
npm install
npm test
# when broken
git bisect bad
# when working
git bisect good
Step 7: Review the result and identify the culprit
# git will output something like:
# abc1234 is the first bad commit
git show abc1234
Step 8: Fix, revert, or patch the broken commit
# to revert
git revert abc1234
# to patch manually
# edit files to fix the bug
git add .
git commit -m "Fix broken feature introduced in abc1234"
Step 9: End the bisect session
git bisect reset
Step 10: Push your fixes and create a pull request
git push origin main
# then on GitHub, click "Compare & pull request"
Conclusion
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.