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