Using Git in Visual Studio


Git is a source code version control system (vcs).  Unlike TFS, Subversion or CVS, which are centrally controlled version controlled systems (cvcs), Git is a distributed version control system (dvcs).  Git was designed and built by the folks who brought us the Linux kernel, including Linus himself.

Git is fundamentally different from other VCS’s in that it is based on the notion that branching and merging are a normal part of every developer’s life.  Because of this, the Git designers built Git so that branching and merging is a relatively inexpensive operation, both at the system level, and at the developer level.  Additionally, since it is a distributed VCS, it is better for some collaboration scenarios. It also doesn’t require the developer to be “online” with the VCS server in order to be productive.  When you do a “checkout” with Git, it grabs your entire repository and pulls it down to your local workstation, so all your operations are local operations.  This tends to manifest itself in much faster operations than other network based VCS’s.

Since Git was designed by the Linux crowd, it doesn’t have a native windows GUI.  Git itself is 100% command line interface (CLI).  It was ported to windows in the form of Msysgit, and can be found here: http://msysgit.github.io/.  Note that this is just the CLI version.  For developers, myself included, who prefer to embrace the GUI aspect of Visual Studio, there is also a Visual Studio Plugin and regular GUI interface called Git Extensions, which can be found here: https://code.google.com/p/gitextensions/.  Git Extensions also has a Visual Studio Add-In for VS2005-VS2012.

In January of 2013, Microsoft announced that they are embracing Git as a VCS.  TFS 2012 now has support for hosting Git repositories.  Additionally, there is an official Visual Studio plugin for VS2012 that will enable full Git support from within the IDE. VS2013 comes with Git as an option straight out of the box.  More info on that can be found here: http://blogs.msdn.com/b/visualstudioalm/archive/2013/01/30/getting-started-with-git-in-visual-studio-and-team-foundation-service.aspx

Because of the novel approach to branching and merging, Git is quickly becoming a major player in the VCS arena. Vincent Driessen has published his version of a successful branching model, and from that came a Git tool called Git-Flow.  Vincent’s write-up can be found here: http://nvie.com/posts/a-successful-git-branching-model/, and the Git-Flow scripts can be found here: https://github.com/nvie/gitflow.

There is also a really great tool you can use to visualize and manage your Git repositories. It’s called SourceTree and is available from Atlassian here: http://www.sourcetreeapp.com/. It also has built-in support for Git-Flow.

Now that Microsoft has jumped on the band wagon, there isn’t much reason not to at least try it out.  Git is a bit different than the traditional approach to VCS though, so I highly recommend reading up on Git culture so as to not confuse terminology.  There is an informative write-up on Git by Scott Chacon called Pro Git. It can be found here: https://github.s3.amazonaws.com/media/progit.en.pdf.

 

SEARCH ARTICLES