Thursday, January 31, 2013

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

Git support for Visual Studio - Git, TFS, and VS put into Context:
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 comment 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 http://tfs.visualstudio.com 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 https://hanselman.visualstudio.com 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.


© 2013 Scott Hanselman. All rights reserved.



DIGITAL JUICE

No comments:

Post a Comment

Thank's!