Improved Git Experience in Visual Studio 2019

Avatar

Pratik

Last week we released version 16.6 Preview 2 of Visual Studio 2019. It contained the first iteration of a revamped Git experience to improve your productivity when working with code on GitHub, Azure Repos, and other hosting services. You can learn more about how to use the entire Git feature set in Visual Studio in our new documentation.

You can enable or disable the experience by searching (Ctrl+Q) for preview features. In the Options window, just toggle the checkbox for the New Git user experience. We acknowledge that the functionality is still incomplete, with more enhancements coming soon. But we do expect this to be the default experience in the future. So in the meantime, we’re depending on you, the community, to let us know what we should prioritize in order to build what you need.

Turn on new Git UX preview feature

Turning on the new Git user experience in Preview Features

Initialize and Push

You can now initialize a local Git repository and push it directly to GitHub, Azure Repos, or other remote hosting services (e.g. BitBucket, custom Git servers, etc.) with a single click. If you have an existing project online, you can use the built-in GitHub and Azure Repos browsing experiences to clone your code.

Initialize and push a repository to GitHub

Initializing and pushing a repository to GitHub

Create new branches

Once your repository is initialized, we want to enable you to focus on your daily development workflows without having to leave your code. You can create branches and commit code changes from the new Git menu and the Git tool window.

Create a branch and commit changes

Creating a branch and committing changes

Manage branches

Context switching between tools and applications can be a pain. So we’ve added the ability to manage your branches from within the Git tool window. After working on your new feature or bug fix, use the branch dropdown in the Git tool window to check out, merge, rebase, view history, rename, and delete your branches.

Merging and deleting a branch

Merging a branch and deleting it

Resolve merge conflicts

We understand collaborating with your team and sharing your work is very important, especially so in the current climate with increased remote work. When it comes to keeping your code up to date, this can be done easily using the fetch, pull, and push shortcuts in the Git tool window. But even when you do your best to stay in sync with the latest code changes, running into merge conflicts is sometimes inevitable. With the improved experience, we’ve started to make it easier to navigate through and resolve your merge conflicts.

Resolve a merge conflict

Resolving a merge conflict

Please Share Your Feedback

This is just the beginning of a new first-class Git and GitHub experience in Visual Studio. Please add or vote for suggestions on the most important functionality that you want us to build or change.

Also be sure to keep these reference images handy for a quick overview of the new Git interface.

Image Git Tool Window Image Git Menu

And finally – stay safe, stay healthy.

84 comments

Comments are closed. Login to edit/delete your existing comments

  • Avatar
    Sławek Rosiek

    In my case I frequently repeat such steps:
    1. Fetch
    2. Find branch remote/master or remote/develop
    3. Merge from
    4. Merge
    Or
    1. Fetch
    2. Find branch remote/master or remote/develop
    3. New branch from
    4. Create branch

    Could you make it requiring less steps. Some suggestions:
    1. Mark branches as favorite so I don’t have to search for remote/master or remote/develop as they are always on top.
    2. Eliminate second merge click
    3. Eliminate fetch click for remote branches (do it automatically)

  • Avatar
    Steve

    Given that there’s always going to be gaps in the GUI commands, e,g, sub-modules, there needs to be a quick way to bring up the command prompt.
    I use Actions=>Open Command Prompt in the old implementation all the time.

    • Avatar
      Pratik NadagoudaMicrosoft employee

      We understand that sentiment. There are a ton of CLI commands and it will take some time to implement even the most popular ones. We’re going to be adding an entry in the Git menu to open the command prompt soon!

  • Avatar
    James Chaldecott

    As you are improving the link between VS & AzDO, is there any chance of a quick fix for this feedback item?

    Basically, the URL used to clone an AzDO git repo if you start from VS isn’t the same as if you start from the AzDO website. The website one includes some extra info that helps the git credential manager pick the right auth mechanism. Without it, LFS gets stuck in a loop asking for credentials.

  • Hesam Kashefi
    Hesam Kashefi

    Support “Git Flow” ( There is an app “Smartgit” that supports Git Flow ) and multiple origins and a good visual representation of branches

  • Avatar
    David Lowndes

    Is there any chance of getting the terminology used with rebase operations clearer?
    Everyone I know (including myself) instinctively think that it’s back to front.

    “Are you sure you want to rebase YourCurrentBranch onto master” – is instinctively read as “you’re going to modify master”, when it’s actually the other way round.

    I know this is likely to be a bone of contention for people steeped in Git, but couldn’t it just say “Are you sure you want apply the latest changes in the master branch onto YourCurrentBranch”?

    • Avatar
      Pratik NadagoudaMicrosoft employee

      Yep I completely understand, and this isn’t the first time we’re hearing about the confusion in the wording. However, it is industry standard wording and so we do want to stay aligned with what everyone is at least used to seeing. I do see the value of a confirmation dialog that explains what is actually going to happen. I’ll look into it, thanks!

  • Jay Asbury
    Jay Asbury

    So when are you going to finally let us stage lines? Sometimes we want to break a change into finer details. Why I am a contributor to and use Git Extensions. Frankly your TFS view of git operations stinks.

  • Avatar
    Matt Graham

    First of all, thank you so much for this! I’ve always found the Team Explorer setup for git to be so poorly designed for git as everything took twice as many clicks as was necessary (or in any other git ui).

    Just downloaded the preview version to check it out and have some thoughts. Apologies if any of this is being planned!

    Any reason why the main branch dropdown doesn’t show a tab remote branches? Looks like you have to create a new branch, then go to remote, then select the branch you want to pull down. Seems like having a remote branch tab in the initial branch dropdown where you could select a remote branch and have it automatically down and switch to it would be more efficient. Plus, in regards to the branch dropdown, right clicking on the branch in the branch selection dropdown should also bring up the menu for that branch so you don’t have to explicitly click on the chevron.

    More minor complaint since it’s just a visual thing, I’m not sure I’m a big fan of the top panel where it shows the branch, status message, and the fetch/pull/push buttons. Mostly I’m not a big fan of the vertically aligned buttons. I think having the status message line taking up the full width of the sidebar so the branch and the buttons could be on the same vertical alignment would look a bit better, personally.

    All in all, though, I’m a huge fan of these changes! Great to see this going in a much better direction than the Team Explorer.

  • Avatar
    Roman Janovský

    Will it be possible to use the features with T4 templates and DTE ExecuteCommand? For example so that the newly created files can be added to source control automatically? Something like command File.AddtoasourceControl but that actually works…

  • Avatar
    Lasse Hansen

    I really wish you’d implement a proper “git mv” for renaming. Renaming and changing files in VS in one go always breaks history.

    I have to work around it by using the Shell, which defeats the purpose of having it integrated.

    It’s already posted as a request, but it doesn’t seem like you understand why.

    • Avatar
      Adam Shortland

      Agree! This is an issue I run across frequently, especially early on in dev cycles where things are coming into the tree quickly and getting renamed/moved frequently, maintaining that history is critical, especially when the original dev is no longer available

    • Avatar
      Pratik NadagoudaMicrosoft employee

      Hey Lasse – I hear you. Although have you tried staging the renamed files before committing? With that workaround, if you stage the added (new filename) and the deleted (old filename), Git’s rename detection will run, and VS will display it as a rename. In this scenario, no history is lost. Can you try if that works for you?

      For general reference, if it’s still a problem, here is the post on Developer Community – https://developercommunity.visualstudio.com/idea/731084/add-team-explorer-git-mv-support-to-moverename-fil.html. Please vote!