A quick look at Git support in Visual Studio 2012 - Jon Galloway

A quick look at Git support in Visual Studio 2012

I use Git a lot these days. My team uses it exclusively for internal work, collaboration with vendors, and public open source releases. I've got several public and private repos on CodePlex, GitHub and BitBucket - open source projects, book sample code, presentation content, etc.

I've used the command line, posh-git, and GitHub for Windows (you knew you can use GitHub for Windows with non-GitHub repositories, right?). I quickly decided that msysgit wasn't helpful, bounced between the command line and Visual Studio for a while, then used the git command line in the Visual Studio Package Manager console.

I've been using GitHub for Windows app a lot since it was released. Some people will make fun of you if you don't use the command line in git; and it's true that the old git windows tools weren't very useful. I've found that the GitHub for Windows client works pretty well for a lot of day to day work, and I can quickly pop open a shell window when I need it (e.g. removing files, merging, git deploy to Azure). If nothing else, GitHub for Windows takes the annoyance thinking about SSH keys out of the picture.

I wasn't sure I'd like GitHub support in Visual Studio, though. It's nice to see file status, history, merges, etc., but I didn't want it locking my files or messing with my project files or... well, changing anything at all. I think of code as files, not a bunch of stuff living in Visual Studio, and I want to manage it.

Disclaimer: There are a lot of good posts about the new Git support in Visual Studio 2012 with lots of nice pictures. I didn't read them, partly because it looked like a lot of work, and partly because I wanted to see if I could just click around and good things would happen. What could go wrong?

tl;dr: It doesn't mess with my code or project files, works well distributed, and integrates cleanly with stuff like .gitignore and .gitattributes. So far I like it. Oh, and it works with Visual Studio Express, too.

Installing the Git tools for Visual Studio 2012

The big Getting Started with Git in Visual Studio and Team Foundation Service post has a Get set up note at the top that worked great for me.

I already had Visual Studio 2012 installed, so step one was installing Visual Studio 2012 Update 2 CTP. I think the download page could be a little more clear - I figured I'd start with the smallest one and it worked on my machine.

Installing Visual Studio 2012 Update 2 CTP 22013-01-30_12h33_33

Note: In case you missed it, Visual Studio's moved to delivering regular updates (with new features) on a shorter delivery interval. Visual Studio 2012 Update 2, a.k.a. VS2012.2, just shipped and has a lot of nice new features (even a blue theme for the nostalgic).

The Visual Studio 2012 Update 2 install took 8 minutes for me and didn't require a reboot - make sure you've got Visual Studio closed when installing the update, of course. Not crazy fast, but barely long enough for me to get a cup of coffee.

Next up was the the Visual Studio Tools for Git extension. I expected this to be a little faster since it's a VSIX, but it was so fast I didn't get screenshot. It installed in maybe 15 seconds - if that. Fast. I, for one, welcome our new VSIX overlords. Fast, lightweight installs are quite nice, and I like that I can disable or uninstall them without fear of setting the house on fire.

Test drive (or, randomly clicking around to see what jumps out at me)

Okay, first I opened up a project I'd previously set up on GitHub. It found the .git folder and shows me status for files - none modified yet, as shown by the blue lock icon thing.

2013-01-31_20h31_33

I noticed a mistake in Default.aspx and deleted it, which shows a red checkmark to show it's been modified. It's pretty small, but I don't think that's a big deal as I'll show in a second.

2013-01-31_20h36_08

I also delete some database files from App_Data that shouldn't have been included. Now I'm ready to commit my change. I'll right-click on the project and pick "Commit..." Note that Commit was disabled until I made this change.

2013-01-31_20h38_27

Okay, now it popped up this Team Explorer thing which shows the changes I've made. The Commit button is disabled and it tells me I need a commit message (standard for a git commit), so I'll need to fill that in.

2013-01-31_20h41_05

After filling in the commit message, I can Commit.

2013-01-31_20h43_24

And then it shows the details from the Commit.

2013-01-31_21h14_08

Now at this point it still sees this as a local repo - it doesn't know that the upstream master is on GitHub. In the spirit of honest dumb guy clicking around, I don't see how to tell Visual Studio about the upstream master to push it.

2013-01-31_20h50_47

Hey, notice that little orange logo next to it? I didn't know what that was, either. It turns out it's the official Git logo. Who knew?

Fine, now let's check this out in GitHub for Windows to see if anything wacky happened.

2013-01-31_21h25_06

Sync from GitHub for Windows works, or I could pop the console and git pull --rebase / git push if I was in the mood.

Oh, one more neat thing - the branch history shows my local commit.

2013-01-31_21h30_08

Summary

I'm happy with this. I opened a project I'd previously created on GitHub, it didn't modify a single file, it read my .gitignore and .gitattributes, and it showed me some useful information. I just clicked around and (1) nothing got messed up (2) I saw some useful information as I was working. I guess that's my point - it didn't hurt anything and I'm happy I installed it.

I checked it out with my CodePlex git repos and they were swell, too.

From some more reading, the real goodness shows up when you use the free (for 5 users or with MSDN account) Git hosting at http://tfs.visualstudio.com, or when you need to do some merges or other more UI oriented things. You can read more from people who aren't just clicking around at some of the following gold certified urls:

Published Thursday, January 31, 2013 8:59 PM by Jon Galloway

Comments

# re: A quick look at Git support in Visual Studio 2012

Great thing it's awesome

Friday, February 1, 2013 4:08 AM by salemsalah

# re: A quick look at Git support in Visual Studio 2012

I ran into the same issue trying to edit an existing project from GitHub.  I couldn't figure out how to tell Visual Studio where the master location was.  If you figure it out, please let us know.  This would make having git support that much more useful.  

Friday, February 1, 2013 10:01 AM by Chris Swain

# re: A quick look at Git support in Visual Studio 2012

Sounds cool, any hope of getting some HG love? Still a much better experience than git even if github made git the cool kid on the block . . .

Friday, February 1, 2013 11:21 AM by Wyatt Barnett

# re: A quick look at Git support in Visual Studio 2012

People should keep in mind that 2012.2 hasn't really 'shipped' yet - what's being recommended above is a first CTP of 2012.2, which doesn't have a 'go-live' licence - i.e. you shouldn't be using this stuff on your production machines...

Thursday, February 14, 2013 9:07 AM by Will