Using Git In Visual Studio



Visual Studio makes this pretty easy by using clearer terminology. In the case of Merge, the master branch file is the Target, and the feature file is the Source. If you used the command git mergetool, master would be LOCAL and feature would be REMOTE. Visual Studio 2013 Update 1 through Visual Studio 2019 version 16.7 have a git client built into Team Explorer. To locate the feature, open a project that’s controlled by Git (or just git init an existing project), and select View-Team Explorer from the menu. You’ll see the ' Connect ' view, which looks a bit like this.

  1. Visual Studio Git Workflow
  2. Using Git In Visual Studio 2015
  3. Use Git Bash In Visual Studio Code

Most of the time the Git integration of Visual Studio Code will do fine. But for other functions of Git the command-line seems more efficient. Once you use git over the command-line you’ll find yourself sometimes using a terminal text editor. Which might be fine for you. But if you’re the integrated terminal in Visual Studio Code it might feel a bit awkward. In this case you can set Visual Studio Code as the default editor for git.

Visual Studio Git Workflow

During this example we will change the global git configuration. You can change the configuration on a repository level too. To do this; make sure you’re in the git repository and lose the --global option.

Set Visual Studio code as git editor#

Using Git In Visual Studio 2015

To set Visual Studio Code as default editor you have to run the following command.

This adds the following configuration to your global git config.

By passing the --wait to the code command you tell Visual Studio Code to wait for you to close the file before returning to the terminal.

Set Visual Studio code as git mergetool#

Besides an editor you can set a merge tool. Ofcourse you can use Visual Studio Code for this too. This is a two step process. First you have to define a new merge tool and secondly you need to set it as the default merge tool.

UsingUsing git in visual studio community 2019

This adds the following configuration to your global git config.

Set Visual Studio code as git difftool#

The same goes for setting the git difftool. You will have to run the following two commands.

This adds the following configuration to your global git config.

2019

Summary#

You can change the git config to use Visual Studio Code instead of a terminal text editor. To do this in one step you can paste the following snippet in your git config file.

Using Git In Visual Studio

Use Git Bash In Visual Studio Code

For more information read the Visual Studio Code docs.