Getting Started With Git-flow

| Comments

If you’re working with git you have definitely heard about git-flow ….. whaaat??….. you haven’t heard of it??…. really???? are you from the moon???? what the heck are you doing??? go and read this!!

UPDATE: Make sure you have xcode installed!

Installing git-flow on Mac OS

i don’t know why, but the homebrew installation didn’t work for me, so let’s go with the manual installation.

first we need to download the project to a local folder into your computer, open a terminal and run the following:

$ git clone --recursive git://github.com/nvie/gitflow.git

Then, you can install git-flow, using (don’t forget to cd to the cloned repo!):

$ sudo make install

By default, git-flow will be installed in /usr/local.

once you have installed it, you can init your repository with (obviously in a git Working Copy):

$ git flow init

this will prompt you some questions on which branches would you like to use as development and production branches, i prefer the default setup, just press Return key on any of those questions.

No branches exist yet. Base branches must be created now.
Branch name for production releases: [master]
Branch name for "next release" development: [develop]
How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []

After you’ve answered the questions, git flow sets your default branch to develop automatically. Now you’ll using git as you normal do, working on small features on the develop branch. If you want to add a major feature that’s when git-flow becomes handy.

start a new feature using:

$ git flow feature start <name>

this will create a new branch called feature/<name> based on develop branch and git-flow automatically switch to it. Now when you’re done, just finish it using:

$ git flow feature finish <name> 

It’ll merge feature/<name> back to develop and delete the feature branch.

nice, right???; What git-flow is doing behind the scenes when you finish a feature branch is the following :

$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff myfeature
Updating ea1b82a..05e9557
(Summary of changes)
$ git branch -d myfeature
Deleted branch myfeature (was 05e9557).

Creating release/hotfix/support branches

git-flow offers you others nice commands that you can work with. all you need to do is follow the same as the feature command.

To list/start/finish release branches, use:

$ git flow release
$ git flow release start <name>
$ git flow release finish <name>

When you finish a release branch, it’ll merge your changes to master and back to develop, also git-flow will create a tag for this release.

To list/start/finish hotfix branches, use:

$ git flow hotfix
$ git flow hotfix start <name>
$ git flow hotfix finish <name>

When you start a hotfix branch, it’s based on master so you can quickly fix it when something is broken on production and when you finish it, it’ll merge it back to master and develop.

To list/start support branches, use:

$ git flow support
$ git flow support start <name>

at the end you’ll see something like this on your history view:

Sync with your remote repo you can sync your local repo with your remote repo using

$ git push --all

or using:

$ git push origin develop

and

$ git push --tags

more info at:

http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/

http://yakiloo.com/getting-started-git-flow/

some screencasts:

A short introduction to git-flow (by Mark Derricutt)

On the path with git-flow (by Dave Bock)

Comments