Enhanced Productivity with Git in Visual Studio

Pratik Nadagouda

We continue to enhance the Git experience in Visual Studio and are excited to announce some long-awaited updates in version 16.10 Preview 2. You can download the latest Preview and run it right alongside your main release, leaving your production installation undisturbed.

In the last iteration, 16.9, we listened to your feedback and focused on fixing issues after the first public release of the Git experience. In 16.10, we’ve built new functionality that addresses gaps around discoverability, switching repositories, navigation, and more!

Enhanced Git tooling in 16.10 preview 2
Overview of Git enhancements (enlarge)

Status bar

The first set of changes is to the status bar. The section of the status bar at the bottom right of the IDE window has a tray of always accessible Git commands. And we started to expand the functionality there.

Branch picker

Beginning with the rightmost button, the well-known branch picker now looks similar to the branch drop-down in the Git Changes window. With this visual overhaul, you’ll have access to search branches and can view both local and remote branches. The context menu gives you actions to perform on a branch, regardless of which tool windows you have visible.

Image 16 10 P2 status bar branch picker

Branch picker in the status bar

Repository picker

The repository button in the status bar now has the first iteration of a repository picker when you select it. You can see all of your local repositories sorted in alphabetical order, and you can filter the list, too. Soon, you’ll be able to remove items from this list as well.

Image 16 10 P2 status bar repo picker

Repository picker in the status bar

Opening repositories

Whenever you open a version-controlled folder or solution for the first time in Visual Studio, you’ll see the associated Git repository appear in your local repositories list along with any of its nested sub-repositories. If the remote of the repository is hosted on Azure DevOps, you’ll get a prompt in Git Changes to connect to the Azure DevOps Project. Doing so will allow you to access Work Items and Builds for the project. And after the initial connection is established, Visual Studio remembers it so that it auto-connects the next time you open the repository.

Image 16 10 P2 connect ado

Info bar to establish initial connection to Azure DevOps project

Solution list

By default, whenever you open a repository, Visual Studio loads the associated solution/folder in Solution Explorer. If you have multiple solutions in the repository, then Solution Explorer displays the list of solutions.

Image 16 10 P2 solution list

List of solutions for the repository in Solution Explorer

Customize repository behavior

There are a few nuances here. Normally, Visual Studio will maintain consistency between the open repository and the open solution so that they are never out of sync. For example, if you switch to a different repository, then the open solution will close and the new solution will open. But we’ve seen situations where your solution might be outside of your Git repository. If so, you’ll want to keep the solution open when you open a repository even though they’re in different folders. Now, you can customize that behavior by toggling the new preference in Git > Settings. 

Image 16 10 P2 close sln setting

Preference to choose whether to close solutions when switching repositories

We’ve also gotten feedback that some developers prefer to use Visual Studio as a Git tool before they start coding. For example, you might want to change branches or pull commits before you open a solution or folder. Our first step to help here is to provide an option to open only a repository, and not any code files with it. This will make Visual Studio essentially a Git-only tool. If you want to open code files, then you can load the solution or folder later.

Image 16 10 P2 open folder setting

Preference to load code when opening repositories

Pending changes

The Changes button in the status bar shows the number of changed files that haven’t been committed yet. It provides a shortcut to open the Git Changes window.

Image 16 10 P2 pending changes

Button to open Git Changes window

Sync commits

And the final button in the status bar shows your Git remote operations. This button displays the number of commits that haven’t been pushed to the remote. And soon, it’ll also show you the number of unpulled commits. When you click this button, you’ll see a new flyout with commands to Fetch, Pull, Push, and Sync (which we brought back by popular demand)!

Image 16 10 P2 status bar sync

Outgoing / Incoming commits dropdown with Sync functionality

Sync is short for Synchronize and is a combination of a Pull and then a Push. The added benefit of the Sync command is that it synchronizes your local branch with the remote in one click. The command is also available in the top-level Git menu, which allows Sync to have its own keyboard shortcut (Alt+G+S) for quick access. It also makes it searchable in the Ctrl+Q search box, if you ever forget where it is.

Image 16 10 P2 git menu

Sync command in the Git menu

Git Repository window

Incoming/Outgoing commits

The first thing you’ll notice in the Git Repository window is the permanent home for the list of Incoming and Outgoing commits. You can now access these sections from the status bar and keyboard shortcut Ctrl+0+Y. The sections give you an overview of all the commits that are yet to be pushed or pulled. When you select Fetch, it will populate the Incoming section. Making local commits will populate the Outgoing section.

Image 16 10 P2 incoming section

Fetch, Pull, and Push buttons in the permanent Incoming and Outgoing sections in the Git Repository section

Embedded commit details

The next thing you might want to do after looking at an outgoing commit is to check what changes were in the commit. Previously, selecting a commit would open a new tool window, and then selecting a specific file to view the changes would open yet another window. That’s too many windows! So, we embedded all the functionality into one single window. You’ll be able to see the details of the commit and a visual of the changes in the first file. You can go down the list of files and view the changes in each file right there. The windows work in the same way when comparing two commits.

Image 16 10 P2 embedded commit details

Embedded commit details and inline file diff in the Git Repository window

And if you want to get a full screen view of the commit details, maybe even pop out a few different commits on different screens to deep dive into the changes, you can do that too! You have full control over the layout of the window.

The toolbar at the top of the file comparison provides you with useful information. The notations on the left tell you the number of deletions and insertions in the file for the selected commit. By using the actions on the right, you can change the layout from side-by-side view to inline view and others.

Image 16 10 P2 popout commit

Popped out tab for commit details with side-by-side file diff

Git Changes window

We’ve consolidated the buttons in the status section of the Git Changes window into a single overflow menu in the upper right corner. From here, you can manage multiple remotes if you have any and perform actions on them. The menu also gives you access to commands for navigation and opening other windows related to your repository such as Settings, Branch History, File Explorer, and Command Prompt.

Image 16 10 P2 git changes action menu

Action menu in the Git Changes window

Learn more

With every new experience, there’s always a change in muscle memory. We think it’s important to provide up-to-date guidance on how to use any new tooling. For that purpose, we’ve created a free online course to learn Git in Visual Studio with step-by-step exercises. Our documentation is also updated with more articles on version control.

Regardless of whether you’ve followed along with our journey from the beginning or are joining us right now, just know that there’s much more to come. We have plans to build many valuable features to help you work with Git repositories in Visual Studio. To help us prioritize, please continue to vote on feature requests, and let us know how we’re doing!