hewking's blog
Author: hewking
Labels: blog
Created: 2024-12-20T11:44:40Z
Link and comments: https://github.com/hewking/blog/issues/26
以下是使用 git bisect 查找 bug 的方法:
git bisect start
git bisect bad
git bisect good <commit-hash>
git bisect good # 如果 bug 修复了
# 或
git bisect bad # 如果 bug 还在
重复步骤 4,直到 git 找到第一个有问题的提交
完成后,重置二分查找:
git bisect reset
实用技巧:
git bisect run <test-script>
自动化测试git bisect log
查看历史记录git bisect skip
跳过无法测试的提交git bisect visualize
查看当前位置测试脚本示例:
#!/bin/sh
# test-script.sh
make && ./my-test
exit $? # 测试失败返回非零值
来源: