| name | git-advanced-3-git-bisect |
| description | Sub-skill of git-advanced: 3. Git Bisect (+2). |
| version | 1.0.0 |
| category | operations |
| type | reference |
| scripts_exempt | true |
3. Git Bisect (+2)
3. Git Bisect
Basic Bisect:
git bisect start
git bisect bad
git bisect good v1.0.0
git bisect bad
git bisect good
git bisect reset
Automated Bisect:
cat > test-bug.sh << 'EOF'
npm test -- --grep "specific test"
EOF
chmod +x test-bug.sh
git bisect start
git bisect bad HEAD
git bisect good v1.0.0
git bisect run ./test-bug.sh
git bisect reset
Bisect with Skip:
git bisect skip
git bisect skip abc123..def456
Bisect Log and Replay:
git bisect log > bisect.log
git bisect replay bisect.log
4. Git Rerere (Reuse Recorded Resolution)
Enable Rerere:
git config --global rerere.enabled true
git config --get rerere.enabled
Using Rerere:
git merge feature-branch
git add .
git commit
git merge another-branch
git rerere forget path/to/file
Rerere Management:
ls .git/rr-cache/
git rerere gc
git rerere diff
5. Git Reflog
Basic Reflog:
git reflog
git reflog --date=relative
git reflog show feature-branch
Recovery with Reflog:
git reflog
git checkout -b recovered-branch abc123
git reflog
git reset --hard HEAD@{2}
git fsck --unreachable | grep commit
git show <commit-hash>
git stash apply <commit-hash>
git reflog
git reset --hard HEAD@{5}
Reflog Expiration:
git config --get gc.reflogexpire
git config --get gc.reflogexpireunreachable
git config --global gc.reflogexpire 180.days