3 ms·
A chronological list of all the commits that affected a line of code. I've often gone and looked at a line, looked at the blame for that line, and then had to t
by jeremy_k 2y ago
A chronological list of all the commits that affected a line of code. I've often gone and looked at a line, looked at the blame for that line, and then had to traverse backwards through history to find where the change I'm interested in happened. Using the GitHub UI, this takes a considerable amount of clicks.
1) Click on a file
2) Click blame
3) Click the parent commit SHA
4) Click View File
5) Click blame
Repeat as you traverse back in history.
- jaredsohn 2y agoHere is how you can do this via the commandline for one or more lines: git log -L 40,50:app/models/user.rb
- sureIy 2y agoI think that will lose track of what you're really after if the function changes enough, or is moved to a different part of the file, or just moved out. Without tools that understand the code (e.g. AI) git alone can't keep track of changes the way humans do.
- jaredsohn 2y agoYeah, you're right. I did a little investigation before posting that and it seemed to handle some movement within the file but after looking at it more closely I see it is not fully robust (even within the same file it misses some earlier changes). This page provides some other techniques: https://tekin.co.uk/2020/11/patterns-for-searching-git-revision-histories https://tekin.co.uk/2020/11/patterns-for-searching-git-revis... but I think they have their own limitations.
- akerl_ 2y agoIn the "Blame" view on Github, you can click the little stacked-rectangles next to a line and it will take you directly to the blame of the commit before that change occurred.