repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

opencode/skills/git-bisect/SKILL.md

Raw

name: git-bisect description: Binary search git history to find when a bug was introduced — git bisect run automation, good/bad commit marking, regression hunting. Use when you know something broke but not which commit caused it. license: MIT

What I do

Find exact commit that introduced a bug using binary search (O(log n) steps).

How It Works

  1. Mark current HEAD as bad
  2. Mark known good commit
  3. Git checks middle commit
  4. Test and mark good/bad
  5. Repeat until found

Basic Workflow

Start

git bisect start
git bisect bad        # HEAD is bad
git bisect good v1.0.0  # Known good

Test

# Run test
cargo test

# Mark result
git bisect bad   # Bug exists
git bisect good  # Bug doesn't exist

Result

a1b2c3d is the first bad commit

End

git bisect reset

Automated

git bisect start HEAD v1.0.0
git bisect run cargo test

Advanced

Skip Uncompilable Commits

git bisect skip

Custom Terms

git bisect start --term-old=fixed --term-new=broken

After Finding

git show a1b2c3d        # Show diff
git blame a1b2c3d -- file.rs  # Find line

Best Practices

Quick Reference

git bisect start
git bisect bad
git bisect good <commit>
git bisect run <command>
git bisect skip
git bisect reset

Use to quickly find bug introduction point.

Markdown source
File outline
---
name: git-bisect
description: Binary search git history to find when a bug was introduced — git bisect run automation, good/bad commit marking, regression hunting. Use when you know something broke but not which commit caused it.
license: MIT
---

## What I do

Find exact commit that introduced a bug using binary search (O(log n) steps).

## How It Works

1. Mark current HEAD as bad
2. Mark known good commit
3. Git checks middle commit
4. Test and mark good/bad
5. Repeat until found

## Basic Workflow

### Start

```bash
git bisect start
git bisect bad        # HEAD is bad
git bisect good v1.0.0  # Known good
```

### Test

```bash
# Run test
cargo test

# Mark result
git bisect bad   # Bug exists
git bisect good  # Bug doesn't exist
```

### Result

```
a1b2c3d is the first bad commit
```

### End

```bash
git bisect reset
```

## Automated

```bash
git bisect start HEAD v1.0.0
git bisect run cargo test
```

## Advanced

### Skip Uncompilable Commits

```bash
git bisect skip
```

### Custom Terms

```bash
git bisect start --term-old=fixed --term-new=broken
```

### After Finding

```bash
git show a1b2c3d        # Show diff
git blame a1b2c3d -- file.rs  # Find line
```

## Best Practices

- [ ] Clean working directory
- [ ] Use automated tests
- [ ] Skip uncompilable commits
- [ ] Examine changes after finding

## Quick Reference

```bash
git bisect start
git bisect bad
git bisect good <commit>
git bisect run <command>
git bisect skip
git bisect reset
```

---

Use to quickly find bug introduction point.