Git:git blameコマンドで開始行と終了行を指定して表示する方法

スポンサーリンク

git blameコマンドで開始行と終了行を指定して表示する方法

git blameコマンドで開始行と終了行を指定して表示するには-Lオプションを指定します。

 

オプションの説明

 -L <start>,<end>, -L :<funcname>
     Annotate only the line range given by <start>,<end>, or by the function name regex <funcname>. May be specified multiple times. Overlapping ranges are
     allowed.

 

-Lオプションを指定した場合

$ git blame -L 20,30 README.md
6164972018b README.md (Matthieu Moy        2016-02-25 09:37:27 +0100 20) See [Documentation/gittutorial.txt][] to get started, then see
6164972018b README.md (Matthieu Moy        2016-02-25 09:37:27 +0100 21) [Documentation/giteveryday.txt][] for a useful minimum set of commands, and
7926cee9046 README.md (Doug Ilijev         2019-07-18 12:08:45 -0700 22) `Documentation/git-.txt` for documentation of each command.
aa98eb3d658 README    (Christian Couder    2009-02-24 21:16:37 +0100 23) If git has been correctly installed, then the tutorial can also be
a299e3a3961 README.md (Benjamin Dopplinger 2016-05-30 03:08:16 +0000 24) read with `man gittutorial` or `git help tutorial`, and the
a299e3a3961 README.md (Benjamin Dopplinger 2016-05-30 03:08:16 +0000 25) documentation of each command with `man git-` or `git help
a299e3a3961 README.md (Benjamin Dopplinger 2016-05-30 03:08:16 +0000 26) `.
aa98eb3d658 README    (Christian Couder    2009-02-24 21:16:37 +0100 27)
6164972018b README.md (Matthieu Moy        2016-02-25 09:37:27 +0100 28) CVS users may also want to read [Documentation/gitcvs-migration.txt][]
a299e3a3961 README.md (Benjamin Dopplinger 2016-05-30 03:08:16 +0000 29) (`man gitcvs-migration` or `git help cvs-migration` if git is
aa98eb3d658 README    (Christian Couder    2009-02-24 21:16:37 +0100 30) installed).

$ git blame -L 20,+5 README.md
6164972018b README.md (Matthieu Moy        2016-02-25 09:37:27 +0100 20) See [Documentation/gittutorial.txt][] to get started, then see
6164972018b README.md (Matthieu Moy        2016-02-25 09:37:27 +0100 21) [Documentation/giteveryday.txt][] for a useful minimum set of commands, and
7926cee9046 README.md (Doug Ilijev         2019-07-18 12:08:45 -0700 22) `Documentation/git-.txt` for documentation of each command.
aa98eb3d658 README    (Christian Couder    2009-02-24 21:16:37 +0100 23) If git has been correctly installed, then the tutorial can also be
a299e3a3961 README.md (Benjamin Dopplinger 2016-05-30 03:08:16 +0000 24) read with `man gittutorial` or `git help tutorial`, and the

 

-Lオプションを指定しない場合

$ git blame README.md | head
9ae7dcb4025 README.md (Johannes Schindelin 2020-04-11 00:18:10 +0700  1) [![Build status](https://github.com/git/git/workflows/CI/PR/badge.svg)](https://github.com/git/git/actions?query=branch%3Amaster+event%3Apush)
5f7864663bd README.md (Johannes Schindelin 2019-01-29 06:19:32 -0800  2)
28513c4f56a README.md (Matthieu Moy        2016-02-25 09:37:29 +0100  3) Git - fast, scalable, distributed revision control system
28513c4f56a README.md (Matthieu Moy        2016-02-25 09:37:29 +0100  4) =========================================================
556b6600b25 README    (Nicolas Pitre       2007-01-17 13:04:39 -0500  5)
556b6600b25 README    (Nicolas Pitre       2007-01-17 13:04:39 -0500  6) Git is a fast, scalable, distributed revision control system with an
556b6600b25 README    (Nicolas Pitre       2007-01-17 13:04:39 -0500  7) unusually rich command set that provides both high-level operations
556b6600b25 README    (Nicolas Pitre       2007-01-17 13:04:39 -0500  8) and full access to internals.
556b6600b25 README    (Nicolas Pitre       2007-01-17 13:04:39 -0500  9)
779d7e93773 README    (Stefano Lattarini   2012-12-14 16:37:47 +0100 10) Git is an Open Source project covered by the GNU General Public