Reputation: 1213
I wondered if any of you knew of a tool that would allow me to select a line in my code and then view a list view of the history of that line on a commit-by-commit basis.
Does anyone know of such a tool?
Upvotes: 105
Views: 89891
Reputation: 16628
In IntelliJ, you can use "Show History for Selection" in the "Git" submenu after selecting a line or multiple lines.
Upvotes: 6
Reputation: 22273
Maybe annotations in IntelliJ IDEA is that you are looking for:
Upvotes: 106
Reputation: 11558
If you would like to view inline
such information then you may add GitToolBox plugin. Live example on YT
Upvotes: 68
Reputation: 32376
If you are using IntelliJ then, its annotation feature provides an option to do the annotation on previous revision. Using this option you can go back to the history of that line.
Find below screen-shot which shows, This option and its available in the community edition as well.
Upvotes: 7
Reputation: 28951
I know only the IntelliJ IDEA "Viewing Changes History for Selection" feature.
You could also try to use several git blame
commands to iterate over history of a fragment.
Upvotes: 61
Reputation: 37896
git-blame
shows what revision and author last modified each line of a file.
When you are interested in finding the origin for lines 40-50 for file foo, you can use the -L option like so (they mean the same thing — both ask for 11 lines starting at line 40):
git blame -L 40,50 foo.txt
git blame -L 40,+11 foo.txt
You can specify a revision for git blame to look back starting from (instead of the default of HEAD) if you want to find out who edited that lines before a specific commit (fe25b6d in this example; fe25b6d^ is the parent of fe25b6d):
git blame -L 40,+11 fe25b6d^ -- foo.txt
Upvotes: 13
Reputation: 37896
git-log
shows commit logs.
You can specify -L option to trace the evolution of the line range given by ",". You can specify this option more than once.
git log -L 40,50:foo.txt
Upvotes: 9
Reputation: 1384
As suggested in one of the comments in Can Git show history for selected lines?
git show $(git blame example.js -L 250,260 | awk '{print $1}')
more info: Every line of code is always documented.
Upvotes: 4