Git blame -- prior commits?
git blame -L 10,+1 fe25b6d^ -- src/options.cpp
You can specify a revision for git blame to look back starting from (instead of the default of HEAD
); fe25b6d^
is the parent of fe25b6d
.
Edit: New to Git 2.23, we have the --ignore-rev
option added to git blame
:
git blame --ignore-rev fe25b6d
While this doesn't answer OP's question of giving the stack of commits (you'll use git log
for that, as per the other answer), it is a better way of this solution, as you won't potentially misblame the other lines.
You can use git log -L to view the evolution of a range of lines.
For example :
git log -L 15,23:filename.txt
means "trace the evolution of lines 15 to 23 in the file named filename.txt".
Amber's answer is correct but I found it unclear; The syntax is:
git blame {commit_id} -- {path/to/file}
Note: the --
is used to separate the tree-ish sha1 from the relative file paths. 1
For example:
git blame master -- index.html
Full credit to Amber for knowing all the things! :)