Git-Log or Git Graph in Visual Studio Code

$ git log --oneline --all --graph

I am working on a tutorial project where I would teach my readers how to code in languages that are available by default in the Windows operating system. We have quite a few of them, and I have decided to start with JScript/ES3. The figure below displays the commit history of the cvmd2html.wsh.js project as displayed by the Git Graph extension in VS Code. I access it from the Status Bar (the blue bar at the bottom of the figure).

Git Graph for cvmd2html.wsh.js

This view is not default. I deselected the Author and Date properties so that the view matches the outcome of the git-log command at the head of this post.

Author and Date are unselected

Right-click on the header row to toggle the visibility of the properties' columns.

Compare the Git Graph view of the project with the result of executing the git-log command below. The commit hash column is not the last in the commit record row, but it is not important at this stage. I will show the formatting of commit logs in another article.

Git-Log from the terminal

Since I installed the Git Graph extension in my preferred IDE, Visual Studio Code, I have stopped typing git-log commands in the terminal shell. It eases investigating my git repositories, and more importantly, I have lots of fun using it. It also comes in handy in many other use cases, but showing prettified git repository history is what attracted me at first.

The built-in Source Control Graph feature in VS Code, available from the Activity Bar (the vertical gray bar below the VS Code logo), offers a similar service. The difference is that the log graph is per branch. It is the same as removing the --all option from the git-log command.

Source Control Graph


An Example Situation

As I wrote earlier, it does not serve the unique purpose of prettifying the commit logs. This view allows us to perform specific actions on individual commits and branches. The video below shows how to create a tag using the built-in Git extension versus the Git Graph extension.

* To open the command palette, press Ctrl+Shift+P in Windows or Command+Shift+P in Mac OS, then type Git: Create Tag in the field popping at the top of the VS Code window to filter the options.
* In the Git Graph view, right-click on the commit message to show the context menu of actions.

The built-in Git extension creates the tag on the current branch only:

$ git tag 1.0.0

The Git Graph extension can create a tag on any commit I select. In this case, I picked the grand-parent of the HEAD commit on the main branch:

$ git tag 1.0.0 main^^

Comments

Popular posts from this blog

Start a Program on the Remote Active Desktop with PowerShell

Git-Commit: Reuse Commit Messages