Introducing GitFlow for Visual Studio

Update: The exension is now also available for Visual Studio 2015 Preview: https://visualstudiogallery.msdn.microsoft.com/f5ae0a1d-005f-4a09-a19c-3f46ff30400a

 

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.

 

Installation

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:

image

Install it and restart Visual Studio, as usual.

 

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:

image

 
Now, if GitFlow is not installed on your machine you will be presented with the following message:

image

By clicking Install, the extension will copy the necessary files into the Git for Windows directory, and run the install script for GitFlow.
You can check the installation details for GitFlow here https://github.com/nvie/gitflow/wiki/Windows

(Note: Since copying files into the %ProgramFiles(x86)%Gitbin directory requires elevated priveledges, this is done by running this as a elevated Powershell script.
You will see this flash by during the installation
)

 

Initialize

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:

 

image

You can also set the Tag prefix, which will be used when you tag a release or hotfix branch as part of finishing up those branches.

Note that all output from all GitFlow operations are sent to a separate output window pane in Visual Studio, which is activated when the command start.
Here you can which gitflow command that were used and the output from it:

 

image

 

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.

 

image

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:

image

 

As you can see, the extension will now suggest Finish Feature as the recommended action:

image

Note that all other actions are still available from the Other menu.

 

In the GitFlow world, you are allowed to have multiple feature branches but only one release and hotfix branch at any single time.
In fact, if you try to create multiple release branches, you will get an error.

Keeping track of multiple feature branches can be cumbersome, so the extension lists all active feature branches is a separate section:

image       image

As you can see, if you hover over a feature will get some more details on it, and if you right-click on it you can (depending on the state), checkout, track or publish the feature branch.
I will be looking at adding more functionality here in the future to make is even easier to use this workflow.

 

I hope you will find this extension useful. Please report any bugs or feedback over at the GitHub site for this extenstion, over at  https://github.com/jakobehn/GitFlow.VS

24 thoughts on “Introducing GitFlow for Visual Studio”

  1. Originally posted on: http://geekswithblogs.net/jakob/archive/2015/02/12/introducing-gitflow-for-visual-studio.aspx#643588

    This is a great value to our team. One idea for a feature request we had was to have an option before starting a release or a hotfix to show the most recent 2-3 tags in the repo. Since we are tagging by version per git flow and thereby naming the release/hotfix by the next version number, I still have to pull up source tree or the repo to get the last version of the specific project we used. This featurewould allows us to completely dump Source Tree 🙂 Great job on such a clean extension!

  2. Originally posted on: http://geekswithblogs.net/jakob/archive/2015/02/12/introducing-gitflow-for-visual-studio.aspx#644157

    @M. Hasim: that is strange. Can you check where you have Git installed? The extension tries to locate the git installation path by first checking the PATH variables, then the registry and the default to program files (x86)gitbin.

    In this path, the extension then installs the git-flow bash scripts a few dll:s that gitflow uses. Can you check if you have these files installed there?

  3. 10x Jakob for this great extension!
    One issue so far, I noticed that when starting a new feature (under VS online), it gets incorrect user name and date. Looks like it picked the guy who created the repo/branches.

    1. Hi Tomer, this is standard Git behaviour. Until you have committed something, the branch points to the previous commit and the corresponding user. Thanks for using the extension!

  4. Hello,
    Sorry i am leaving a comment here since your book post does not allow me to comment. Does your latest Apress book cover Git on TFS ?

    Thanks

    1. Hi! It does not cover Git in any detail, it does talk about important practices around source control management when it comes to continuous delivery, such as branching patterns, branch policies and protecting your mainline. I don’t know of any good material on Git in TFS, there is of course a lot of material on Git.

  5. How do i Initialize / Confirm the settings are correct if the initialize button was never shown ?

    My GIT was already working before installing GitFlow and it picked up SOME settings … but when i start a feature it doesn’t end up in the correct “folder” …

    1. If your git repository was already configured for gitflow, the extension will pick this up. gitflow stores it settings in the config file, located in the .git directory of your repository. You can change your settings there

  6. Looks like a great add-in, thanks for making it.

    You can also use SourceTree that also have great support for git flow, and more room to implement it on (-: Team explore is to cramp for my test.

    But some people prefer to leave VS.

  7. After I originally commented I clicked the -Notify me when new comments are added- checkbox and now every time a remark is added I get four emails with the same comment. Is there any way you’ll be able to remove me from that service? Thanks! http://eurospinz24.ru

  8. Hi I have tried the add-in and have some questions around rebasing.

    When a conflict exists during a rebase:

    1) Will any support be added to redirect you to the merge conflicts screen directly to resolve them?
    2) Will any support be added to display the “continue rebase” menu option when conflicts are resolved without running command line?

  9. Hi! I have a question about Pull Requests and GitFlow. Does it make sense to incorporate pull requests into the GitFlow plugin?

    Example 1) “Finish release” merges the “Release branch” into local master and origin/master if specified. But in this case the testing should have been done in the release branch, therefor no need of a pull request?
    Example 2) “Finish feature” merges the feature branch only to the local develop branch? In this case there will be no need for a pull request from the plugin? Or does the “Finish feature” also have the option to merge to origin/develop?

Leave a Reply

Your email address will not be published. Required fields are marked *

*