Scott Hanselman

Git support for Visual Studio - Git, TFS, and VS put into Context

January 30, 2013 Comment on this post [76] Posted in Open Source | VS2012
Sponsored By

VS loves GitDogs and cats, living together...mass hysteria. This classic Ghostbusters quote is used by many geek-types (myself included) whenever something crazy or unexplained happens.

Today Brian Harry from Microsoft announced Visual Studio 2012 Update 2 (or VS2012.2) the latest quarterly update. That's interesting, but it's the announcement of Git integration with Visual Studio and TFS that is really significant, in my opinion.

TFS in the Past

For me personally, the term "TFS" has historically meant "big scary corporate centralized source control" while Git has meant "small scrappy lightweight distributed source control." TFS meant connected (ZOMG, I can't code on a plane!) and Git meant occasionally connected (ZOMG, I don't know what rebase means!).

However, I learned that Team Foundation Server (TFS) isn't just source control, it's a whole bug tracking, change management, application lifecycle management (ALM) suite. Source control is one pluggable piece.

On the other hand, Git isn't just source control either. Git has become effectively FTP for code. I use Git to deploy most of my sites as mentioned in this blog post where have a site automatically deploy as I publish to GitHub. Git is also used as an interchange tool to move code between different SCMs, and it's supported everywhere, although Git tooling support on Windows has historically lagged behind.

Things start getting interesting if one could have Git as their source control with Team Foundation on the backend for ALM tools. Now Visual Studio 2012 supports both centralized version control and distributed version control in a cleanly integrated way.

Open Source - Working WITH Git

So Visual Studio is integrating Git. Suspicious? This might sound like the "embrace and extinguish" Microsoft from the 90's. Arguments can always be made, but I'm a coder, so I look at the code.

If you dig into the GitHub repo, you can see at least five Microsoft employees (phkelley, ethomson, jamill, martinwoodward, congyiwu) submitting pull requests to the libgit2 GPLv2 library (GPL'ed with a linking exception), including direct commits from phkelley who has earned that access. They work with all the libgit2 committers including Vicent Marti from GitHub. The team has been doing this for months and months. In fact, if anyone was paying attention to commits and pull requests they would have seen this whole convergence coming down Main Street.

 Libgit2 is a great library with a lot of attractive features (from their site):

  • written in portable and standards compilant C
  • completely multi-platform: Windows, Linux, Mac OS X, xBSD and more
  • compiled natively under all platforms (yes, even MSVC on Windows)
  • re-entrant, with sane error handling
  • designed with a solid and consistent API
  • available as bindings for all major scripting language

You can see below that this new Visual Studio Git support actually ships git2 and libgit2sharp and integrates it via a VSIX (Visual Studio Extension).

git2 and libgit2sharp

Visual Studio and Git

This Git support will require VS2012.2 (currently in preview) so you'll need to install that first, then get the VSIX. You'll be able to update both when VS2012.2 is released, and the Git VSIX will continue to update automatically via the VS Gallery. It's a full source code provider for VS so you can use it to do most anything without leaving VS, or you can hang out at the command line and use it for a visual reminder as to the state of your repository.

One file added, one file modified

You can see what will be included in a commit and what's excluded:

Commits to git, both included and excluded

You can make new branches, check them out, as well as see what branches are published or unpublished.

branching in Git in VS

In this screenshot you can can see Keith and I going back and forth on a Pull Request. Note that I've allowed VS in Git Settings to go to Gravatar and get a picture of Keith.

Git History and Gravatars in VS

Here's a screenshot of me managing a recent merge conflict with the VS diff editor then committing the change and pushing it to GitHub. All the diffing is integrated as you'd expect it to be, and available via a Right-Click.

Diff/Merge Conflict within Visual Studio with Git Support.

What's next?

I'm told that while this Git integration is currently in preview. The team work on a three week sprint cadence so expect to see frequent updates.  The plan is that in a future release Git will come baked in to all editions of Visual Studio - including Express. Perhaps we'll see PoshGit command line integration/support and maybe better support for the Git command line within the NuGet Package Manager Console inside VS.

Git within the NuGet Package Manager Console

Hosted Team Foundatation Services - Git or TF Version Control

You can use VS Git support with all your Git projects by just opening projects. It's just Git. I am pushing branches to CodePlex, to GitHub and other Git repos. I'm also continuing to use my other Git tools interchangeably, as I like.

Some teams I work on use Git, others  use TFS. It depends on the team, the company and the goals. Some teams have servers they run themselves, some use hosted Git services at BitBucket or GitHub. There's also hosted Team Foundation Services.

For teams, you can go up to and sign up for a account and get 5 users for free. You can choose either Git or Team Foundation Version Control (TFVC) as the source provider and use all the Team Foundation agile, scrum or other templates for your ALM tools. I've actually got now for my "team." There's issue tracking, backlogs, scrum templates, a Kanban board, burndown charts and more. You can use the web app or use the Visual Studio integration to manage your bugs and backlog. There's even cloud build servers in preview.

TFS online kanban

I've said this before, but I'll say it again. This kind of open source collaboration stuff is why I went to work for The Man. Playing well with others, competing well while using and promoting open source. I don't think every group at Microsoft "gets" it yet, but it's cool to see the open movement spreading. I'm looking forward to using these Git tools for Visual Studio, as well as GitHub for Windows and PoshGit.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
January 30, 2013 21:49
This is great news.

Congrats to the team. You deserve a lot of credit too Mr. H. Your job disseminating this kind of news is incredible helpful for us mere "devs".

January 30, 2013 21:49
So Visual Studio is integrating Git. Suspicious? This might sound like the "embrace and extinguish" Microsoft from the 90's. Arguments can always be made, but I'm a coder, so I look at the code.

I know you have been trolled so much recently. But haters will always hate. Let's stop being apologetic. Microsoft is taking long big strides towards OSS and you are doing a great job - ignore trolls.
January 30, 2013 21:51
Scott - what's the story regarding an open solution when changing a branch? Has this somehow improved with this?
January 30, 2013 21:59
Welcome brothers, come on in the water is fine.
January 30, 2013 22:00
Forgot to point out libgit2's GPLv2 + Linking Exception license, without which it couldn't be used in Visual Studio.
January 30, 2013 22:03
What is the story for git submodules like. This seems to be a sticking point for a lot of git solutions other than the command line so far.
January 30, 2013 22:13
Is this going to be available for VS 2010?

I love the new way that MS is going :)

January 30, 2013 22:20
This is awesome. Thanks for the good news...

Could an existing TFS project be used with the Git provider as the client? Or in other words, how does this wave of git changes affect the tfs-git (or git-tfs) integration ?
January 30, 2013 22:27
Great news!
im really in need for good source control.
to be honest i dont have much exprience with git or any other major source control provider..
i wish a good tutorial will follow the new release.
cause this tool seem very useful and productive.

Great Job!
January 30, 2013 22:31
Hari - Yes, you can still use git-tfs. They are looking at ways to integrate that even tighter, but I expect lots of folks will use Git locally and then push to a central TFS.

Miladin - I don't think so.
January 30, 2013 22:35
good news
January 30, 2013 22:52
Eric - It works well. Everything you do from the command line gets reflected in the GUI instantly. I've changed branches, added stuff, etc and VS keeps up. If you change a project file it will pop a dialog and you can click Reload All.
January 30, 2013 23:00
Miladin, I would highly doubt VS2010 will see this support. The company I just started for cannot even buy a new license key for VS2010, or find one for purchase anywhere. It appears MS is forcing everyone to 2012.
January 30, 2013 23:07
@perry -> I don't think it likes submodules -- I'm just playing with it right now with a solution (with it's own git repo) that has two projects (each in their own submodule) and it doesn't seem to work right. I'm really not sure *what* it's thinking.
January 30, 2013 23:18
Glad to provide a few commits and a merge conflict for you to demonstrate, Scott. ;)

It would be neat if it came in the box, but for now posh-git should work in the Nuget console without issue - just clone it somewhere on your machine, make sure git is in your PATH (or add an alias) and run install.ps1 from the Nuget console.

@Perry - This uses LibGit2Sharp under the hood, which will have submodule support as soon as we get around to finishing it. I can't speak to when or how it would manifest in the VS experience.
January 30, 2013 23:37
@Keith => Looking forward to the submodule support :D
January 30, 2013 23:54
Interesting to me that Microsoft prefers a bunch of PInvokes (WinRT 'native code love'-style) while Mono dynamically translates NGit from Java... apparently an only-C# Git isn't worth the effort! (Honestly: nice to see wheel re-use, just sad to see the two wheels.)

At least Mono gets points for including SSH support front-and-center, it's not immediately clear to me whether or not libgit2 does.
January 31, 2013 0:09
Exciting news Scott !!!! Just last week I was listing to Phil Hack on .net rocks and the same question about "VS support for GIT hub" came up and I was wondering when this would happen. I didn't expected it so soon. I am sure the entire .net community would just love to see this coming.
January 31, 2013 0:18
"Mispellings everywhere"

I hope that's supposed to be a pun.
January 31, 2013 0:20
Absolutely love this new direction! Keep it up!

Any chance the same love will be shown for Mercurial\Hg?

January 31, 2013 0:26
This is AWESOME! Love the way MS is going on the .net platform. The more MS empowers the devs on it, the longer .net lasts and becomes stronger, which in turn gives life to the entire Microsoft product ecosystem.

Thanks Scott and VS team!
January 31, 2013 0:50
Greaaat news.

Just a quick one - that conflict resolution, is that 2 or 3 way merge ?
January 31, 2013 1:09
I use PowerShell to handle my code and notes.
I created a guide to set it up here:
January 31, 2013 1:30
PoshGit integration would be killer.
January 31, 2013 1:51
This is great! I hope one day Microsoft'll open up some of their larger projects like Visual Studio or even Windows!
January 31, 2013 1:52
very interesting for me
January 31, 2013 2:18
Switching branches with VS open kills me every time. Can't tell you how many times I've been bitten by this. Windows in general is agressive with locking files. At least once a week I have a "git pull/merge" fail that requires me to close VS, close Windows Explorer and/or close Sublime Text in order to continue.
January 31, 2013 4:18
Matt, we will not be supporting Mercurial. Git is our DVCS.
January 31, 2013 7:32
Best news I've heard all day!! I had given up on Git & VS integration, but this makes me a happy person :)
January 31, 2013 7:47

Libgit2 contributor here. I can't speak to Microsoft's motivations in choosing libgit2 to base their git support on, but I can speak to our project goals. We aim to provide git functionality to other programs in any language, not just CLR languages. GitHub itself uses the library through rugged, for example.

As for SSH support, @schu is still working on it. We'll get there. :)
January 31, 2013 11:03
Great news! Can't wait to try it.

I hope they will integrate soon something like GitDiffMargin - A Visual Studio 2012 extension to display Git Diff on the margin of the current file.
January 31, 2013 13:21
This is good news but I'm sad to see Mercurial being shunned once again :(
January 31, 2013 13:32
Nice to see Microsoft producing good Git-tooling for Windows-developers.

Is this all actually a move to get Phil Haack back to Microsoft? :P
January 31, 2013 17:18
@Keith Is there a specific bug ticket in github for lib2git for submodules? I am really hoping for a good solution for sub modules soon.
January 31, 2013 17:26
I have GitStack running on a WHS2011. How do I connect from within VS2012? I can add TFS servers, but I don't see it for Git.

January 31, 2013 17:39
Olivier, you'll need to install a couple of things for VS 2012. The following blog post will provide the details.

To use the Visual Studio client tools you'll need to install Visual Studio 2012, apply Visual Studio 2012 Update 2 CTP, and finally install Visual Studio Tools for Git You can use these client tools with any Git service you want.
January 31, 2013 18:31
Buck, thank you for your reply. I had everything installed already, it's just not clear where you would add git servers.

From what I see now, you must add every git project manually via the clone command. Maybe I'm not seeing something, but this screenshot from the Getting Started article shows a git logo under the Team Foundation Server list. That's what I was looking for...
January 31, 2013 19:42

Thanks for the git support, but I hate that Mercurial was informally supported then dropped. Why do y'all hate Python? ;)
January 31, 2013 22:04
Thanks for such nice article,

I've been using .git with VS2010 (+ git extensions) from last couple of months. Its integration with appHabour is awesome.

I am looking this new native behavior.

February 01, 2013 0:50
@Perry - See #220 and #274.
February 01, 2013 1:12
@Oliver: To get a Git repository to show up under "Team Foundation Service" you have to "connect" to a TFS hosted Git repository. That is, you can create new Git Team Projects on Once you connect to that project from within VS, it will show up under "Team Foundation Service".

If you want to use a repo that is hosted on GitStack or GitHub, it will only show up under "Local Repositories" but you can still use the Commits and Branches pages to work with the remote (it will look for origin).
February 01, 2013 4:42
"You can see what will be included in a comment and what's excluded..."

" a 'commit' surely..."
February 01, 2013 13:59
@Taylor: Thanks for the clarification, it makes sense. The UI could perhaps be a little clearer, but it works for now.
February 01, 2013 18:24
When trying to add my existing project to my Git repository at through VS2012 (after installing update 2 and the Git tools), I get a messagebox saying:

The 'SccProviderPackage' package did not load correctly.

The error refers to an activity logfile where the two last entries are errors:

<description>SetSite failed for package [SccProviderPackage]</description>
<errorinfo>Method not found: 'System.Collections.Generic.Dictionary`2<System.String,System.String> Microsoft.TeamFoundation.Client.TeamExplorerProjects.GetProjectProperties(System.Guid, System.String)'.</errorinfo>

<description>End package load [SccProviderPackage]</description>
<errorinfo>Method not found: 'System.Collections.Generic.Dictionary`2<System.String,System.String> Microsoft.TeamFoundation.Client.TeamExplorerProjects.GetProjectProperties(System.Guid, System.String)'.</errorinfo>

What gives?
February 01, 2013 21:26
Nevermind. Did a repair on the Update 2 and reinstalled the Git tools and it now works :-)
February 03, 2013 23:19
@Keith- So it looks like you are already well on the way to supporting it.

Does anyone know if there is going to be support for pushing/pulling from repositories other than TFS Servers? i.e. github?
February 04, 2013 8:55
@Perry - this release can talk to any git server (at least any server that supports smart HTTP) be it github, bitbucket or Team Foundation Service.
February 04, 2013 16:13
Hi guys,

cool to see Git-Integration.

I've tried it and it seems to work.
How can I change the password though? I've changed my password on github and now whenever I want to push an update onto the remote repository I get a 401, since the password I entered the first time is not valid anymore.

February 04, 2013 17:18
Sorry for double post, but it seems I found where to change the password. It is stored in Windows under the Credential Manager, which you can access under Windows 7 in "Control Panel\User Accounts and Family Safety\Credential Manager"!

Hope it will help someone else and sorry for not searching in depth more before!
February 04, 2013 18:40
@Edward When I try to pull from my github repo I get the following error.
An error was raised by libgit2. Category = Net (Error).
This transport isn't implemented. Sorry
How do I set it up to be able to pull/push from github?
February 04, 2013 22:00
@Perry - Right now only HTTP/HTTPS endpoints are supported. If you change your remote to be HTTPS instead of SSH, it should work fine. Eg:

git remote set-url origin

We'll make this a better experience in the next preview release, but SSH is going to take us a bit longer.
February 04, 2013 22:01
Also, as for the credential store / password changing issue, we've logged it and will also have that fixed for a future release. Thanks!
February 05, 2013 0:04
Hi Scott (and others),

First of all, a big thanks to you guys at Microsoft for taking this path. I don't directly work with Visual Studio myself, but I've tried helping out those who do with their Git issues, and this will be of big help, both directly and indirectly for wider adoption and use of Git.

I've tried to paint a little overview of the Git tooling around for the Windows platform. Perhaps some other readers will find it useful when navigating around the Git tools available.
February 05, 2013 23:54
Tried this out today, no support for autocrlf makes this add-in DOA. I do not want to be forced to have Windows line endings in my central repo and trying to have Visual Studio use Unix line endings requires yet another add-in.
February 06, 2013 8:56
@Jonathan - The VS tools don't require CRLF line endings in the central repo. The default .gitattributes file that we shipped isn't right - we shipped with "* -crlf" but we quickly realized we should have set the default to "* text=auto". We'll fix the default file in an upcoming update, but in the meantime you should be able to use any setting you like for line endings and normalization.
February 07, 2013 20:14
It's great to see Microsoft taking steps to support Git!

I myself am a heavy user of the rebase feature, and I hope it'll be integrated nicely at some point! The UI is quite difficult to use but this is a preview so you guys have the time to improve it. A cool view with all the branches and their associated commits would be great!

Keep up the good job!
February 07, 2013 22:15
I love the GIT integration, bug tracking, story planning, it really helps with small teams to be able to have one place for all of this cool tools... I currently use GITHub and AppHarbor for continuous deployment, I would like to use TFS and Azure with GIT as the SC provider, but I cannot get that to work. Azure does not recognize TFS GIT projects... has anyone figured a way for this to work?
February 18, 2013 8:15
hello my friend
March 13, 2013 21:31
I'm at Pycon 2013 and assume I am the only Visual Studio user in the room. This kind of support from Microsoft is my only hope. I want to continue to write apps in .NET, but I need to be empowered to work with Open Source as well using these tools, e.g. PTVS, Git support, etc. So...many thanks to you, and please pass the love around to the rest of Microsofties, who "get" it. We need this kind of cross-pollination to continue...
March 29, 2013 1:58
This is simply amazing ! Well done !
March 29, 2013 21:21
It's sad to see Microsoft jumping on the open source bandwagon instead of creating a viable commercial alternative. But then again, Microsoft was never much of an innovator to begin with.

Git is like using a chainsaw with thousands of switches and buttons and all of them labeled in Greek. In the hands of someone who spent months learning it, it can be efficient productive and fast, but to the rest of us mortals, learning to use it can take off a few fingers and possibly your HEAD. Yes, you can always get your fingers and head back, but figuring out how is so difficult, you might as well opt for a transplant (which is also supported by git).

At its core, Git is a big leaky abstraction. It's like driving a model T, where the developer needs to know how it works in order to drive it. I'm tired of all the developers who claim using Git is easy. If it was so easy, why are there so many clueless developers asking questions on Stackoverflow on how to use it. Every GUI for git fails spectacularly because the buttons and switches bubble up to the surface like methane seeping from sludge at the bottom of the lake. You can't get around the Git stench--it sucks!

Thanks to this move by Microsoft, version control will continue to suck and developers will get sub optimal results with it because not all of them have been graced with aspbergers. Developers will continue to struggle with the crap, just like we struggle with HTML/CSS today. There will be hundreds of GUIs out there claiming to make it manageable but it won't happen just like it hasn't happened for HTML/CSS.
April 04, 2013 10:39
This is great, but we really need ssh support which would make it easier to use with custom servers (e.g. gitolite) without having to setup http(s) endpoints.

Hopefully ssh will be there in the final version.
April 10, 2013 14:18
@Joel Beazelman: wrong, wrong, and thrice wrong.

Firstly, Git is easy to use for the vast majority of the time. Yes, there will always be occasions (using any version control system) when you need to perform some action more complex than those used in your usual daily routine, and some of those might prompt you to elicit some outside help, but that doesn't detract from the system as a whole. In fact, if Git (or any SCC system) hid all those internals away so you couldn't access them when you needed to, that would make it significantly more frustrating to use.

Version control doesn't suck like it used to- I have been using various source code control systems from SourceSafe through to CVS and SVN, and Git is a revelation - entirely because it supports the kind of development workflows I am used to by making branching and merging a snip.

Microsoft haven't come up with their own version because it's simply not worth it. The vast majority of the development community is behind Git at the moment (which I'm pretty sure they wouldn't be if they concurred with your opinion), so it makes the investment unlikely to pay off.

As for 'leaky abstraction' - you are misusing the term. Git doesn't aim, and wouldn't benefit from a different level of abstraction. You just need to understand the concepts behind it & then it makes sense. Understanding new technology concepts is par for the course as a developer.
April 23, 2013 13:50
i am using https url, but got error

An error was raised by libgit2. Category = Net (Error).
Response status code does not indicate success: 401 (Authorization Required).
April 23, 2013 13:52
I do not see any way to push my code to github using microsoft plugin...
May 05, 2013 23:49
@Vasiliy You may open command prompt and simply use "git push"
I firstly setup my git repo
git remote add origin ssh://....
so I push origin to it
git push -u origin --all
every time I commit, I simpy push it
git push

my 2 cents
May 24, 2013 13:38
In the screenshot above the folder Controllers is missing the status icon.

How can we get status icons not only for files but also for folders in the Solution Explorer?

PS: is this a Visual Studio prolem?

May 28, 2013 15:57
Scott - I was wondering if you knew if there was a way with either the Microsoft hosted TFS or Git to make project public for people to view the progress and or source code similar to the way GitHub does? I have a few open sourced projects that I would like to work on and open to the community similar to the way GitHub is set up. I like the TFS and Git integration with the free hosting and VS2012, but don't want to have to publish my stuff in both places. I was also thinking about Codeplex, but still that would be in several locations.

Thanks as always
May 30, 2013 0:31
This tool and GitHub integration is the most unintuitive someone could have think on... I hope it will get fixed...
June 06, 2013 10:34
@Jhon: Actually, the most difficult thing to be fixed is the brain of the users. Git is different, but the more you use it, the less you want to go back, and the more you see it is elegant and technically natural. The problem is that computers are not clairvoyants and what seems to be "natural approach" for the user is often the result of overlooking some ambiguous detail.
June 07, 2013 11:03
An error was raised by libgit2. Category = Net (Error).

Use command line (git push) will fix it.
June 26, 2013 23:56
my problem is how to get the elder version of my application pushed into bitbucket with Visual studio 2012(C#). because with the last version of this application i removed accidentally a huge number of code lines. thanks in advance
August 02, 2013 5:24
Finally git is integrated into VS2012!
I highly recommend the TSF project management webapp for one-man shops. Nice bug tracking tool.

I can clear my checklist: use git source control: done!!

All my c# classes are now nicely tracked. Lotsa code, lotsa work!

Thank you for this article!

I'm liking the new MS...

unity in code is unity in life!

September 15, 2013 13:03
Simply awesome! Excelent post as always :)

Git is the source control I've been wishing for all my life and so nicely integrated straight into vs! The feature I love the most is the local commit.

I only wish for more configuration features integrated into vs, like setting your preferred merge and diff tool. I'm unable to remove the horrible kdiff tool on my work devbox, even when following various tutorials from IE stackoverflow. Would be nice if this
September 17, 2013 7:21
Well, it *looked* good. But even though I was able to create a local Repo and even get a TFService account and create a Repo there, Visual Studio simply refuses to publish the local Repo, claiming that the service returned a 404 error code. No real explanation beyond that.

I tried the command line (and, yeah, set up alternate credentials, etc), but that didn't work either: when I attempted to create a remote repo, it (correctly) claimed that the remote Repo was present, but when I tried to push to it, claimed that it couldn't find it.

Any ideas as to what this might be? There's not much that's jumping off the page.


P.S. The Team Foundation Service guides seem *definitely* out of date.
November 03, 2013 4:21
I have been trying to get Visual Studio 2013 to clone a googlecode repository with no luck. I just get:

"An error occurred. Detailed message: An error was raised by libgit2. Category = Net (Error). Unable to read data from the transport connection: The connection was closed."
I even tried git-credential-winstore, thinking there could be some authentication issue. No luck.

VS2013 is able to interface with existing googlecode repos, but I can't convince it to clone. Has anyone had success with this or know what the issue is?
Looking around, SSH transport is known to fail in a similar way, but HTTPS should be working...

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.