IT系/リファレンス/Gitコマンド/git_bisect

Last-modified: 2020-05-31 (日) 14:32:32

git bisect

バイナリ検索を使用してバグを引き起こしたコミットを見つけるコマンド。

用例

  • 問題がない(good)時点と問題がある(bad)時点を指定
    git bisect start <bad-commit> <good-commit>
  • テストスクリプトを指定
    git bisect run <テストスクリプトのファイル名>
  • 手動でテスト:テストの結果、問題がない(good)場合
    git bisect good
  • 手動でテスト:テストの結果、問題がある(bad)場合
    git bisect bad
  • git bisect が現在チェックアウトしているコミットを確認
    git bisect view
  • 二分探索の過程を確認
    git bisect log
  • git bisect を実行する前の状態に戻す
    git bisect reset

書式

git bisect start|bad|new|<term-new>|good|old|<term-old>|terms|skip|reset|visualize|view|replay|log|run|help [options]

公式によると以下の通り。

git bisect start [--term-{old,good}=<term> --term-{new,bad}=<term>]
                 [--no-checkout] [<bad> [<good>...]] [--] [<paths>...]
git bisect (bad|new|<term-new>) [<rev>]
git bisect (good|old|<term-old>) [<rev>...]
git bisect terms [--term-good | --term-bad]
git bisect skip [(<rev>|<range>)...]
git bisect reset [<commit>]
git bisect (visualize|view)
git bisect replay <logfile>
git bisect log
git bisect run <cmd>...
git bisect help

options

--no-checkouto not checkout the new working tree at each iteration of the bisection process. Instead just update a special reference named BISECT_HEAD to make it point to the commit that should be tested. This option may be useful when the test you would perform in each step does not require a checked out tree. If the repository is bare, --no-checkout is assumed.

説明

バイナリ検索アルゴリズムを使用して、プロジェクトの履歴のどのコミットがバグを引き起こしたかを発見するコマンド。

  • このコマンドはさまざまなサブコマンドと、サブコマンドに応じて異なるオプションを指定する。
  • 最初にバグを含む「悪い」コミットと、バグが混入する前の「良い」コミットをコマンドに指定する。
  • コマンドは、次にこれら2つの間のコミットを選択し、選択したコミットが「良い」か「悪い」かを確認してくる。バグが混入したコミットが見つかるまで範囲を狭め続ける。
  • バグ以外にも、git bisectは、プロジェクトのある特性を変更したコミットを見つけるために使用できる(ベンチマークのパフォーマンスを向上させたコミットなど)。
  • このより一般的な用法をサポートするために、 "良い"と "悪い"の代わりに "古い"と "新しい"という用語を使用することも、独自の用語を選択することも可能。

関連

参考リンク

その他メモ

なし。