git blame
git
書き方
git blame [-L <start>,<end>] <file>一行ごとに最後に変えたコミットを添えて見せます。整形だけのコミットが本当の作者を隠すので、-wや--ignore-revを使います。
よく使うオプション
| オプション | 意味 |
|---|---|
| -L <a>,<b> | only those lines |
| -w | ignore whitespace, so re-indenting stops hiding the author |
| -C | follow code moved in from another file |
| --ignore-rev <rev> | skip a commit, e.g. a bulk reformat |
| -e | show email addresses instead of names |
| -s | drop the author and date columns |
例
git blame -L 40,60 src/app.tswho last touched lines 40 to 60
git blame -w -C src/app.tslooks past whitespace and moved code
git blame --ignore-rev 9f3c2ab src/app.tsignores the commit that reformatted everything
取り消しに何通りもあるのが混乱のもとです — ブランチの指す先を動かすのと、打ち消すコミットを積むのは別です。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. git blame は何をしますか。
一行ごとに最後に変えたコミットを添えて見せます。整形だけのコミットが本当の作者を隠すので、-wや--ignore-revを使います。
Q. どう打ちますか。
git blame [-L <start>,<end>] <file> — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは6個です。全部は man git にあります。このコマンドはgitの仲間です。
関連するコマンド
man ページ: man git-blame