git blame
The git blame
command is used to know who/which commit is responsible for the latest changes made to a file. The author/commit of each line can also been seen. git blame
does not show the per-line modifications history in the chronological sense. It only shows who was the last person to have changed a line in a document up to the last commit in HEAD
.
Line between 2 and 4:
1 |
git blame -L 2,4 index.txt |
2 lines after 2:
1 |
git blame -L 2,+2 index.txt |
Make the output shorter:
1 |
git blame -s -L 2,+2 index.txt |
Only display email of the auther:
1 |
git blame -e -L 2,+2 index.txt |
get the blame for a specifi commit:
1 2 |
git blame 9c94fe72ae72680c844ac49443b6617bc26e7b07 -- index.txt git blame HEAD -- index.txt |
When the commit ID is 00000000000
it means I have changed that line locally.
git blame
does not show the per-line modifications history in the chronological sense. It only shows who was the last person to have changed a line in a document up to the last commit in HEAD.
In order to see the full history/log of a document line, you would need to run a git blame path/to/file
for each commit in your git log. Since Git 1.8.4, you can use git log
has -L
to view the evolution of a range of lines.
1 2 |
git log -L 2,4:index.txt git log -L <upperLimit >,<lowerLimit>:<path_to_filename> |