Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Git

Git: Use Git Bisect to Find Bugs with Binary Search

- 05.07.26 - ErcanOPAK

🔍 Git Bisect = Binary Search for Bugs

Bug appeared but don’t know when? git bisect finds the exact commit. Binary search through history. Find bugs fast.

📝 Bisect Commands

# Start bisect
git bisect start

# Mark current commit as bad
git bisect bad

# Mark known good commit
git bisect good commit-hash

# Or from specific commit
git bisect bad bad-commit-hash
git bisect good good-commit-hash

# Git checks out a commit
# Test if bug exists
# Mark as good or bad

# Mark current commit as good
git bisect good

# Mark current commit as bad
git bisect bad

# Git continues bisect
# Repeat until bug found

# Show bisect log
git bisect log

# Reset bisect
git bisect reset

# Visualize bisect progress
git bisect visualize

🎯 Complete Workflow

# 1. Find a bug
git log --oneline
# abc1234 (HEAD) Latest commit
# def5678 Fix something
# ghi9012 Bad commit (bug introduced)
# jkl3456 Previous good commit

# 2. Start bisect
git bisect start

# 3. Mark bad
git bisect bad HEAD

# 4. Mark known good
git bisect good jkl3456

# 5. Git checks out a commit
# Bisecting: 2 revisions left to test after this (roughly 2 steps)

# 6. Test the code
# Run tests, check for bug
# If bug exists:
git bisect bad

# If bug doesn't exist:
git bisect good

# 7. Repeat until Git identifies the commit
# abc1234 is the first bad commit

# 8. Show details
git show abc1234

# 9. Reset
git bisect reset

✅ Advanced Bisect

  • Automate with script: git bisect run test.sh
  • Start with good/bad commits
  • Use git bisect visualize to see progress
  • Save bisect log for later
  • Reset after finding bug

“Git bisect finds bugs fast. Binary search through commits. Essential for debugging.”

— Debugging Expert

Related posts:

Git: Use .gitignore to Exclude Files from Version Control

Git: Use git cherry-pick to Copy Commits Between Branches

Git: Use git cherry-pick to Copy Specific Commits Between Branches

Post Views: 7

Post navigation

Ajax: Fetch vs Axios — Choosing the Right HTTP Library
.NET Core: Manage Configuration with AppSettings

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (857)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (597)
  • Add Constraint to SQL Table to ensure email contains @ (582)
  • Average of all values in a column that are not zero in SQL (545)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (512)
  • Find numbers with more than two decimal places in SQL (460)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes
  • Ajax: Use Axios for HTTP Requests
  • JavaScript: Understand Hoisting
  • HTML: Use Web Storage for Client-Side Data
  • CSS: Use Filter Effects for Visual Magic
  • Windows 11: Unlock God Mode for All Settings

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (857)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com