For a given commit, I need to run blame on the previous version of each line changed but said commit.
Having a commit that changes lines 2 and 3 on file a, I want a way to see the output of git blame commit^
limited to the preamble and the lines 2 and 3.
How can I do that?
Seems like I have to explicitly specify that I'm looking for a way to do the above programmatically, and not examining the commit with my own eyes, determining which lines of which files where changed, and then manually run git blame for each single changed file.
The report does not tell you anything about lines which have been deleted or replaced; you need to use a tool such as git diff or the "pickaxe" interface briefly mentioned in the following paragraph.
Blaming only a limited line range Sometimes, You don't need to blame the entire file, you just need to blame in a limited line range. Git blame provides the option for that. -L will take the option for the start line and for the end line. The above command will blame from line 80 through line 100.
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. There are many other options for blame, but generally these could help.
You can also quit the git blame window using the q key on your keyboard. Now, if you want to learn more about what changed in a commit, simply copy the commit hash and use git log as follows. You should be able to see the full commit message, what lines are removed and what lines are added since the commit before it.
You can try:
git blame <commit>^ -- filename | head -3 | tail -2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With