Visual Studio 2013 and TFS 2013 have both native support for Git. Not all advanced features are supported in the Visual Studio UI, so there might be some situations where you have to do this from command line.
Introduction
When you are working with your Git repository, you will be notified to download and install 3rd-party Git command prompt tools. Those tools will be installed by using the Web Platform Installer. If you closed the notification, you can get the download link from the Settings Hub in Team Explorer.
Working from the command line is fairly easy. You simply go to “Actions” and choose “Open Command Prompt” in any of the Git related Hubs in Team Explorer.
So, this wasn’t that difficult, right? You can read about the third party tools as well as which command work from the UI and from the command prompt from this MSDN page.
Setup up the Command Line and PowerShell
If you open the command prompt directory and not from Visual Studio, you will notice that the Git command is unknown. First of all we need to add the path to the Git binaries to the system path variable. The binaries are installed under:
1: C:\Program Files (x86)\Git\bin
Go to: “Computer –> Properties –> Advanced System Settings –> Environmental Variables” and append the path from above to the variable value.
After having updated the path variable, the Git commands will now work on our system. Now, let’s have a look at Powershell. We can just use the Git commands the way we do in the Command Prompt. When working with the command prompt, you might end up by the following warning: “WARNING: terminal is not fully functional – (press RETURN). You can solve this error by adding another system variable.
1: TERM=msys
Using PowerShell Extension posh-git
Now, we will add a PowerShell extension for Git, called “posh-git”. This is a set of PowerShell script which provide Git/Powershell integration. In this case, we will use PsGet (a PowerShell package management tool) to install the extension.
To get PsGet, simply execute the following command:
1: (new-object Net.WebClient).DownloadString(“http://psget.net/GetPsGet.ps1”) | iex |
Now install the extension by calling:
1: install-module posh-git
When you now reopen the PowerShell console, you will notice the command prompt extension when you access a Git repository.