A journey to .Net

Integrating Git into Visual Studio 2010

Saturday, 24 July 2010 00:10 by mBerube
(Also available in: français)

In the previous post, I talked about Git, a distributed version control system. The classic way to use Git is to use the bash command line. But if you use Visual Studio, you have some extensions you can use to integrate all the goodness of Git into your favourite IDE. Although I still need the command line tool to do some tasks like doing rebase and dcommit on the subversion server, most of the things you need during development are available in your IDE.

Git source control provider

This extension (downloadable from the visual studio extension gallery) set Git as your source control provider. This tool is pretty limited but have 3 interesting features :

  • It displays the name of the current working branch at the top of the solution explorer
  • It shows the status of the files in the solution explorer (added, modified or unchanged)
  • It give a shortcut to open the Git bash windows in a specific solution folder

git source control provider

This extension by itself give really basic functionalities but with the addition of the git extensions for visual studio, it becomes more interesting.

Git Extensions

This extension can be downloaded from Google code and add many Git commands into Visual Studio and Windows Explorer. You can see in the picture above that Git source control provider include a shortcut for Git Extensions but you can use it by itself.

In Visual Studio, Git extensions add a new tool bar and a new menu into the IDE. By these menus and toolbars, you can do much of the day to day work with Git (you can see the new tool bar in the red circle).

git extensions menus

To be honest, I don’t know yet what all these options do but here’s a quick explanation for some of them :

  • Checkout branch : switch from the current branch to another branch. More details on this in a following post.
  • Commit : commit the change in the current branch to the local repository. See below the picture of the commit window.
  • Edit .gitignore. Allow you to set the .gitignore file for your local repository. You can do it manually but if you’re a .Net developer, I suggest you take the default template for .Net that exclude all the temp files. So far, I don’t find any missing files or files that should be exclude.
  • For all the remote features (Manage remotes, pull, push, rebase, etc.), I didn’t try them yet because I never used a remote Git repository for now.

Some more explanations about the commit process. When you want to commit something, you open the commit window :

git commit window

In the top left part, you select the files you want to commit and you click "Stage selected file” to include them in the commit. You must enter a comment in the right bottom section and click “Commit” to confirm. If the file has a change status “Untracked”, it means it’s a new file and the code part (top right) will show the source code. If the status of the file is “Modified”, the code part will show a diff between the 2 versions. Really useful. If you want to rollback a change to the previous version, select the file(s) to want to be rolled back and click “Reset changed”.

I think that’s enough for now. Next post, I’ll talk about branching and merging with Git, with both Git Bash and Git Extension.

Thanks, happy programming.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Git | Programmer life
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRss comment feed