Git Blame
is a tracking command used in Git to find the Author Name and commit information of the last modified version of the source file.
You can see information related to each line of the file by using this command.
The syntax for the simple Git blame command is:
$ git blame YourFileName
The syntax will give information for each line in the following sequence:
Commit Hash(short) | Author Name | Date | Time |
---|
//Example
7009f2ae (Alice 2021-03-01 03:45:03 +0301 3) <head>
$ git blame YourFileName -L StartingLineNo,EndingLineNo
//$ git blame YourFileName -L 3,10
OR
$ git blame -L StartingLineNo,EndingLineNo YourFileName
//$ git blame -L 3,10 YourFileName
$ git blame -L StartingLineNo,+NoOfLines Along With StartingLine YourFileName
//$ git blame -L 3,+10 YourFileName
//It will display lines from LineNo 3 till 12
$ git blame -L StartingLineNo,-NoOfLines Along With StartingLine YourFileName
//$ git blame -L 30,-10 YourFileName
//It will display lines from LineNo 21 till 30
$ git blame YourFileName --since=5.days
//Only Display changes made within Last 5 days
OR
$ git blame --since=2.weeks-- YourFileName
//Not display changes older than 2 weeks
$ git blame -w YourFileName
$ git blame YourFileName -e OR $ git blame -e YourFileName
With this, you will see the original author instead of the one who copied the lines:
//Within same File
$ git blame -M YourFileName
//From Other Files
$ git blame -C YourFileName
//It will Display LongCommit hashes instead of Default shortCommit hashes
$ git blame -l YourFileName
$ man git-blame OR $ git help blame
git config --global alias.YourAliasName blame
//Examples
git config --global alias.who blame // Will change Git blame to Git who
OR
git config --global alias.praise blame
//will change Git blame to Git praise