Essentially what I am trying to do is that same thing we usually do using the web interface. I know how to do git blame
using the web interface say bitbucket or github, but how do you do the same thing using git CLI ? So far I have got thus far:
git grep <line of code that I am interested to see the blame>
. Get a list of files then find the one that I am interested in.git blame <on file of interest>
. Shows who did what and commit hash.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.
On GitHub.com, navigate to the main page of the repository. Click to open the file whose line history you want to view. In the upper-right corner of the file view, click Blame to open the blame view.
To use Git on the command line, you will need to download, install, and configure Git on your computer. You can also install GitHub CLI to use GitHub from the command line.
I stumbled on this http://zsoltfabok.com/blog/2012/02/git-blame-line-history/ after I posted this, so I am going to post this here for reference. The steps are:
git blame -L <starting line number>,<ending line number> <filename>
. (i.e. line numbers are comma-separated, no space)git show <commit hash>
will show you what you need to know.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