Git blame is used to see the last commit and the last author who has modified for each line in the file.

In other words, using git blame, you can see the entire git revision of the file with respect to each line.

Git blame will come in handy when you want to which commit is responsible for the changes and which author has committed those changes.


git blame <file_name>

In the above example, I have blamed for a file. You can see the short commit hash, author name, and timestamp for each line throughout the file.

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.

git blame <file_name> -L 80,100

The above command will blame from line 80 through line 100.

In the above example, see the starting line and the ending line.

Blaming by commit timestamp

You can also blame by commit timestamp

git blame <file_name> --since=3.days

This command will blame commits that are more than 3 days old.

#git #software-development #coding #programming #github

How to use Git Blame Effectively
3.65 GEEK