Git support for Visual Studio - Git, TFS, and VS put into Context
Dogs 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.
- Download Visual Studio Tools for Git
- (read it all, note the VS2012.2 prerequisite at the bottom)
- Getting Started with Git on Visual Studio
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).
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.
You can see what will be included in a commit and what's excluded:
You can make new branches, check them out, as well as see what branches are published or unpublished.
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.
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.
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.
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.
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.
About Newsletter
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.
I love the new way that MS is going :)
Regards
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 ?
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!
Miladin - I don't think so.
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.
At least Mono gets points for including SSH support front-and-center, it's not immediately clear to me whether or not libgit2 does.
Any chance the same love will be shown for Mercurial\Hg?
Thanks,
Matt
Thanks Scott and VS team!
Just a quick one - that conflict resolution, is that 2 or 3 way merge ?
I created a guide to set it up here: http://bakgaard.net/?cat=7
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. :)
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.
Is this all actually a move to get Phil Haack back to Microsoft? :P
Thanks!
http://blogs.msdn.com/b/visualstudioalm/archive/2013/01/30/getting-started-with-git-in-visual-studio-and-team-foundation-service.aspx
To use the Visual Studio client tools you'll need to install Visual Studio 2012, apply Visual Studio 2012 Update 2 CTP http://go.microsoft.com/fwlink/?LinkId=273878, and finally install Visual Studio Tools for Git http://go.microsoft.com/fwlink/?LinkID=275845. You can use these client tools with any Git service you want.
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...
Thanks for the git support, but I hate that Mercurial was informally supported then dropped. Why do y'all hate Python? ;)
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.
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).
"...in a 'commit' surely..."
The 'SccProviderPackage' package did not load correctly.
The error refers to an activity logfile where the two last entries are errors:
<source>VisualStudio</source>
<description>SetSite failed for package [SccProviderPackage]</description>
<guid>{7FE30A77-37F9-4CF2-83DD-96B207028E1B}</guid>
<hr>80131513</hr>
<errorinfo>Method not found: 'System.Collections.Generic.Dictionary`2<System.String,System.String> Microsoft.TeamFoundation.Client.TeamExplorerProjects.GetProjectProperties(System.Guid, System.String)'.</errorinfo>
<source>VisualStudio</source>
<description>End package load [SccProviderPackage]</description>
<guid>{7FE30A77-37F9-4CF2-83DD-96B207028E1B}</guid>
<hr>80131513</hr>
<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?
Does anyone know if there is going to be support for pushing/pulling from repositories other than TFS Servers? i.e. github?
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.
Thanks!
Hope it will help someone else and sorry for not searching in depth more before!
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?
git remote set-url origin https://github.com/name/project
We'll make this a better experience in the next preview release, but SSH is going to take us a bit longer.
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.
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!
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.
Hopefully ssh will be there in the final version.
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.
An error was raised by libgit2. Category = Net (Error).
Response status code does not indicate success: 401 (Authorization Required).
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
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? http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2937726-allow-to-set-source-control-status-icons-for-folde
Thanks as always
Use command line (git push) will fix it.
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!
iL
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
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.
TIA
Josh
P.S. The Team Foundation Service guides seem *definitely* out of date.
"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.
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".