Now Up To 80% OFF
Our Lowest Price of the Year Sale Ends Oct 21st
Search
Close this search box.

Git Blog

Releasing the Power of Git

Enhancing your Python Projects in VS Code

Enhancing Git Management in Python Projects

Git is an essential tool for version control, whether you are a developer or an IT pro. Git allows engineers to track changes, collaborate, and manage their code effectively. However, for beginners, navigating Git can be daunting. 

Enter GitLens, a powerful Visual Studio Code (VS Code) extension designed to enhance Git capabilities and simplify Git management. This article aims to guide Python beginners on using GitLens to streamline their Git workflow, focusing on key features like the commit graph and Launchpad.

What is GitLens?

GitLens is a VS Code extension that supercharges the built-in Git capabilities, making it easier to visualise, understand, and manage your Git repositories. It provides an intuitive interface and powerful features that help both beginners and experienced developers.

Installation and Setup

Getting started with GitLens is straightforward:

  1. Open VS Code.
  2. Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing Ctrl+Shift+X.
  3. Search for “GitLens” and click “Install”.
  1. Once installed, you may need to reload VS Code to activate the extension.

For initial configuration, GitLens works out of the box, but you can customise settings to suit your workflow by accessing the GitLens settings in VS Code.

Key Features of GitLens

GitLens boasts several features that enhance Git management:

  • File and Line History: Allows viewing the history of specific files and lines to track changes over time.
  • Authorship Details: Provides insights into who modified the code and when.
  • Code Lens Integration: Displays Git blame information and recent change annotations inline with your code.
  • Repository Comparisons: Compares branches, tags, commits, and more directly within VS Code.
  • LaunchPad (pro feature): Allow you to perform common Git operations quickly 
  • Code Suggest (pro feature): allows easy collaboration and lets you annotate comments or code suggestions from your IDE. 
  • Cloud Patches (pro preview feature): easily and securely share code with your teammates helping to facilitate better collaboration. 
  • Worktrees (pro feature): allow you to work on multiple branches simultaneously. 
  • Visual File History (pro feature): this feature allows you to visualise your repository and its history. 
  • Commit Graph (pro feature): Visualises the commit history, branches, merges, and individual commits.

Commit Graph

The commit graph in GitLens is a powerful visualisation tool that displays your repository’s commit history. It helps you understand the history of development, track changes, and see how branches and merges have evolved.

Accessing the Commit Graph

There are several ways to open the commit graph, the first way is to

  1. Open the Source Control view by clicking the Git icon in the Activity Bar.
  2. View the commit graph on the “Commits” tab.

The second way is to click on the commit graph icon in the bottom panel:

And the third way is by clicking on the “GitLens” tab within the Terminal view. 

Interpreting the Commit Graph

The commit graph visualises the repository’s commit history, showing branches, merges, and individual commits. Each node represents a commit, with lines connecting them to indicate the flow of changes. This visual representation helps you understand the project’s evolution and identify key changes.

Below is a commit graph for a python repository I have been working on, trying to write a simple To-Do app.  I can see the various branches I’ve created, the merges I’ve made, and the volume of changes I made during each commit. 

If we look at another repository with years worth of commits and lots of branch merges into the main production branch we can see a much more complex history explained very easily using the commit graph: 

Having this rich history allows you to know who has made changes, when changes were made that might have started to introduce issues, and why a change was made. 

Launchpad

With the Launchpad feature you have a unified view that consolidates pull requests from multiple repositories, placing them within your IDE. Helping you to prioritise, act promptly and efficiently collaborate with your teammates. 

Launchpad will periodically check into your source control repositories and highlight pull requests that are for your attention, or pull requests that might need your attention.

When I open Launchpad, it categorises the actions I might have to deal with. In the current view I have in the screenshot below, I have a merge request for the repository I am working on right now, it’s showing in two places.  

It’s being highlighted due to the branch I am currently working on and it’s also in the blocked category.   It’s showing as blocked because it needs action by a human before the merge can happen.  

I also have 7 actions that I’ve snoozed and don’t want to focus on right now. 

If I click on the merge request for the repository I am working on, I can see a bunch of additional actions – I can assign reviews, open the details, open changes, suggest additional code changes or open the commit graph. 

Launchpad periodically checks for changes in the background as I work, so it won’t interrupt me, and I can interact with it when I am ready in my workflow.  By default it checks every 30 minutes for changes, but you can change this to a shorter or longer time, or even disable it checking automatically.  

Conclusion

GitLens is a powerful tool that enhances Git management in VS Code, making it an excellent choice for Python beginners. By utilising features like the commit graph and launchpad, you can gain a better understanding of your project’s history and streamline your workflow. Start using GitLens today and transform your Git experience.

Additional Resources

By leveraging these resources, you can further enhance your Git and GitLens skills, making your Python development process more efficient and enjoyable.

Like this post? Share it!

Read More Articles

Make Git Easier, Safer &
More Powerful

with GitKraken
Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.

Team Collaboration Services

Secure cloud-backed services that span across all products in the DevEx platform to keep your workflows connected across projects, repos, and team members
Launchpad – All your PRs, issues, & tasks in one spot to kick off a focused, unblocked day. Code Suggest – Real code suggestions anywhere in your project, as simple as in Google Docs. Cloud Patches – Speed up PR reviews by enabling early collaboration on work-in-progress. Workspaces – Group & sync repos to simplify multi-repo actions, & get new devs coding faster. DORA Insights – Data-driven code insights to track & improve development velocity. Security & Admin – Easily set up SSO, manage access, & streamline IdP integrations.
winget install gitkraken.cli