GitFlow for Visual Studio
I know, I know... I've been highlighting a number of Git related extensions recently. And I know all of YOU are using Git already (just like I am... um... errr.... um... kind of... yeah).
Okay, fine, so I'm a Git noob. Right now Git continues to gain support, mindshare and seems to one of those things just about every Dev will need to learn. Like many of you, I'm trying to wrap my head around it, more importantly how to do it "right."
Sure creating a repo is easy, and the commit/push/pull/sync seems straight forward (well for my single person projects at least ;). But even there, what's the "right" way to layout the repo, what kinds branches, etc., etc.
Yeah, yeah, I know that there are many "right" ways. And everyone one have positives and negatives. But for me, I don't know what I don't know yet. I just need to start with a good "right" until I can make an intelligent call (no snarky comments from the peanut gallery please... ).
When I saw today's project, I found my first "right" way...
In this post I present the development model that I’ve introduced for all of my projects (both at work and private) about a year ago, and which has turned out to be very successful. I’ve been meaning to write about it for a while now, but I’ve never really found the time to do so thoroughly, until now. I won’t talk about any of the projects’ details, merely about the branching strategy and release management.
While there is nothing really shocking new to this branching model, the “big picture” figure that this post began with has turned out to be tremendously useful in our projects. It forms an elegant mental model that is easy to comprehend and allows team members to develop a shared understanding of the branching and releasing processes.
GitFlow is a popular workflow that provides a consistent naming convention to your branches as well as clear guidance on how your code should flow through these branches.
GitFlow was introduced by Vincent Driessen in this post back in 2010, and quickly caught a lot of attention in the community. Since GitFlow by nature is very prescriptive it made a lot of sense to implement tooling support for the workflow, which Vincent added shortly after. His repo is available at https://github.com/nvie/gitflow, although it hasn’t been updated since 2012.
However, several forks has been made, one of the most active is being developed by Peter van der Does at https://github.com/petervanderdoes/gitflow
To make GitFlow more approachable I decided to integrate the GitFlow toolset into Visual Studio, by extending Team Explorer. This makes it very easy to access the commands and lowers the learning curve a bit by making it available as a UI. Note that the extension includes the GitFlow scripts from Peter van der Does fork of GitFlow and uses them for every command, so it provides the exact same
functionality as the GitFlow scripts does.
Note: The extension requires Visual Studio 2013 Update 3 or higher
You’ll find the extension over at the Visual Studio Gallery, just search for GitFlow in the Extension and Updates Window.
Or, download it from https://visualstudiogallery.msdn.microsoft.com/27f6d087-9b6f-46b0-b236-d72907b54683:
Using the extension
When you connect to a Git repo in Visual Studio (either local or remote), you will see a new icon show up on the home page in Team Explorer:
Now, you are ready to start use the extension! The first thing you will have to do is to initialize the repo for GitFlow. What this means is that you should create your permanent development and master branches, and set the naming conventions for future feature, release and hotfix branches:
Working with features
From now on, the extension will show the recommended actions based on which branch you are currently in. After initializing the repo, you will be in the develop branch, so from here you would typically either start a new feature, release or hotfix branch.
Clicking Start Feature will let you define a name for the branch. GitFlow will add the feature branch prefix for you so don’t include that.
Here I have created a feature branch called SingleSignOn:
As you can see, the extension will now suggest Finish Feature as the recommended action:
Note that all other actions are still available from the Other menu.
I hope you will find this extension useful. Please report any bugs or feedback over at the GitHub site for this extension, over at https://github.com/jakobehn/GitFlow.VS