Whenever I need to make a change to a file that includes a part I don't grasp I try to gather as much informations as possible. One tool that turned out to be very helpful to build up context was seeing who wrote the code & when.
In this lesson I demonstrate you how this can easily be achieved using the VS Code GitLens extension and how to set it up in a way that it's not constantly bothering you.
Instructor: [0:00] Let us install the VS Code extension, Gitlens. Then, let's open a file inside a Git repository. In my case, I'm opening the tooltip implementation of the read GI library. Once you install gitlens, you will see an annotation next to every line.
[0:18] Here, you can see where I made a change five month ago. If you hover over it, you also can see further details of this commit. On the next line, [inaudible] changes three months ago. The same information will also be available in the bottom toolbar.
[0:35] Having this information is especially great if encountering a line with a purpose you don't understand and potentially want to change it. Having the information who wrote the line and when provides a lot more context to help you making better decisions.
[0:50] If this is yet not enough, you can activate the Blame limitation for the whole file with the icon on the top right. Select the commit and see which parts of the file were manipulated with the same commit.
[1:04] Personally, I don't need the commit information all the time and I'd rather prefer a cleaner editor view. If you do two, I recommend turning off the current line limitation but keeping the bottom bar. You can do this by opening the UI settings, filter by GitLens current line, and deactivate the option. As you can see, the notation is not visible anymore, but the bottom toolbar still is.
[1:33] By the way, when you click on the bottom toolbar, a dialog will pop up giving it tons of options, like opening a commit in GitHub or open a revision of this file with this commit.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!