DEV Community

yysun
yysun

Posted on

Commit to Git in Visual Studio 2019

Visual Studio 2019 was launched on April 2nd, 2019. I have migrated my Git Tools extension to a new extension, Git Tools 2019 in order to support the new asynchronous extension architecture of Visual Studio 2019.

Git Tools/Git Tools 2019 extensions add the Git Changes Window to Visual Studio to help you to create granular commits. This post explains how to use the Git Changes Window.

Install

Run Visual Studio 2019; select top menu "Extension"; search the Visual Studio Marketplace for Git Tools and install.

install

You can select the menu "Extensions | Git Tools | Git Changes" to bring out the Git Changes Window.

Git Changes Window

Git Changes Window

The Git Changes Window displays the changes in the Git repository. ❶ By clicking the changed files, the diff viewer on the right side shows the file content differences. ❷ It lets you review the changes.

Simple mode

You can double click the changes in the diff viewer. ❷ It loads the changed file into the main code editor and navigates to the changed line. ❸ It lets you adjust and refine your code. Once you are satisfied, you can select the file(s) ❹, enter comments ❺, and commit.

Step ❶ to ❺ completes committing code in the Simple Mode. The benefit of the Simple Mode is that it hides the concept of Git staging area/index, which makes it easier for beginners, as well as simplifies the commit workflow.

The Git Changes Window is modeled after the Pending Changes Window in Visual Studio 2010, which was unfortunately removed from Visual Studio 2013.

Advanced Mode

The Git Changes Window also has the Advanced Mode. In the Advanced Mode, it displays both the changes and stages changes. ❶ The diff viewer provides more menus. ❷ It allows you not only to stage and un-stage the files but also to stage and un-stage the selected part of the files. As well as to reset/undo the selected part of the files. ❸

Advanced mode

The Git Changes Window is better than the out of the box Visual Studio Changes Page of the Team Explorer. The Git Changes Window is usually docked to the IDE to display the changes automatically. You can review and adjust the changes easily and create granular commits in Git.

Creating granular commits is the primary goal of the Git Commit best practices. Git Tools/Git Tools 2019 extensions provide the nice Git Changes Window inside Visual Studio to help developers to archive the goal. The Git Changes Window is the unique feature of Git Tools/Git Tools 2019 extensions.

I only focused on the Git Changes Window and left out other Git features to be implemented by Visual Studio itself and other Git GUI Tools.

Other Git Tools

If you have installed Git Extensions or TortoiseGit, you will see more menus to launch Git Extensions or TortoiseGit commands in the "Git Tools" menu and in the Git Changes Window.

Git-Ext

Git-Tor

Open Source Project

I developed the first extension to support Git for Visual Studio 2008/2010 when very few people believed that Git would become so popular as today. Eventually, Microsoft has supported Git officially since Visual Studio 2013. However, Git Tools/Git Tools 2019 still provides extra features and values to developers by enabling them to follow the Git commit best practices.

Git Tools/Git Tools 2019 remains as an open source project. You can find the source code from Github: https://github.com/yysun/git-tools.

Please donate or support the project on Patreon. 👍❤️🙏

Have fun until next time.

Top comments (0)