git bisect
git
用法
git bisect start <bad> <good>不断把提交区间对半切,找出第一个出问题的提交;结束时必须 git bisect reset,否则你会一直停在游离的提交上。
常用选项
| 选项 | 含义 |
|---|---|
| start <bad> <good> | begin, naming a broken and a working commit |
| good | mark the checked-out commit as working |
| bad | mark it as broken |
| skip | this commit cannot be tested |
| run <cmd> | let a command decide by its exit code |
| reset | stop and go back to where you were |
示例
git bisect start HEAD v1.1.0starts the search between the last release and now
git bisect run npm testfinds the first failing commit with no further input
git bisect resetends the session; skipping this leaves you on a detached commit
难的地方在于撤销有好几种:把分支的指向挪走,和补一个反向提交,不是一回事。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. git bisect 是做什么的?
不断把提交区间对半切,找出第一个出问题的提交;结束时必须 git bisect reset,否则你会一直停在游离的提交上。
Q. 怎么写?
git bisect start <bad> <good> —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 6 个,完整列表在 man git。这条命令属于git。
相关命令
man 手册: man git-bisect