用 git bisect 定位回归问题

通过标记好坏提交来二分查找历史。

macOSdiff 文件对比Git命令行低风险
运行 git bisect start,把当前提交标为 bad,再用 git bisect good 标注已知正常版本。

01命令

命令
$ git bisect start && git bisect bad && git bisect good v1.0

02作用说明

bisect 会在已知好与坏之间检出提交并等待你测试,每次将范围减半。长历史下几分钟即可定位问题,手工排查则可能要数小时,还能用 git bisect run 自动化。

03风险

风险低风险
使用条件Git 2.20+ (install with Homebrew or Xcode Command Line Tools)
系统兼容性macOS with Git installed (Homebrew or Xcode Command Line Tools)
!注意: 测试可能需要构建或运行任意提交的代码;注意不可信的构建脚本。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • git-bisect documentation
    Git · vendor-doc · 2026-09-20
    依据: Documents git bisect, which binary-searches history to find a bad commit.

最后验证: 2026-10-13 · 分类: 开发者