By Oliver Davies / @opdavies
"A collection of Git extensions to provide high-level repository operations for Vincent Driessen's branching model."
master
: production codedevelop
: development codefeature/
: a specific task or ticket (multiple)release/
: temporary release branch for testing (single)hotfix/
: temporary branch for emergency fixessupport/
: experimentalmaster
develop
develop
~ $ brew install git-flow
~ $ apt-get install git-flow
~ $ yum install gitflow
~ $ git flow help
# Shows the standard help menu
~ $ git flow {subcommand} help
# Shows the help menu for a specific subcommand
~ $ git flow init
~ $ git flow init
No branches exist yet. Base branches must be created now.
Branch name for production releases: [master]
Branch name for "next release" development: [develop]
~ $ git flow init
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? []
~ $ git flow init -d
# Accepts the default branch names.
$ git flow feature
list
: lists all featurescheckout
: checks out an existing featurestart
: starts a new featurefinish
: finishes a featurepublish
: pushes a feature into a remote repopull
: pulls a feature from a remote repo
~ $ git flow feature start {name}
~ $ git flow feature start foo
Switched to a new branch 'feature/foo'
Summary of actions:
- A new branch 'feature/foo' was created, based on 'develop'
- You are now on branch 'feature/foo'
Now, start committing on your feature. When done, use:
git flow feature finish foo
~ $ drush dl admin_menu
~ $ git add sites/all/modules/contrib/admin_menu
~ $ git commit -m "Added admin_menu"
Ensure that your feature is up-to-date
~ $ git flow feature rebase
Will try to rebase 'foo'...
First, rewinding head to replay your work on top of it...
Applying: Added admin_menu
~ $ git flow feature finish {name}
~ $ git flow feature finish foo
Switched to branch 'develop'
Updating 5c04d5a..6487134
Fast-forward
...
31 files changed, 5051 insertions(+)
Deleted branch feature/foo (was 6487134).
Summary of actions:
- The feature branch 'feature/foo' was merged into 'develop'
- Feature branch 'feature/foo' has been removed
- You are now on branch 'develop'
And repeat...
$ git flow release
list
: lists existing releasesstart
: starts a new releasefinish
: finishes a release
~ $ git flow release start {version}
~ $ git flow release start 2014-03-02.0
Switched to a new branch 'release/2014-03-02.0'
Summary of actions:
- A new branch 'release/2014-03-02.0' was created, based on 'develop'
- You are now on branch 'release/2014-03-02.0'
Follow-up actions:
- Bump the version number now!
- Start committing last-minute fixes in preparing your release
- When done, run:
git flow release finish '2014-03-02.0'
~ $ git flow release finish {version}
~ $ git flow release finish 2014-03-02.0
...
Deleted branch release/2014-03-02.0 (was f2aee7d).
Summary of actions:
- Latest objects have been fetched from 'origin'
- Release branch has been merged into 'master'
- The release was tagged '2014-03-02.0'
- Release branch has been back-merged into 'develop'
- Release branch 'release/2014-03-02.0' has been deleted
~ $ git push --all
# Push the changes to the remote branches.
~ $ git push --tags
# Push the tags.
~ $ git flow release finish -pm {message} {version}
# Specify a commit message and automatically push the changes.
~ $ git flow release finish -pm 2014-03-02.0 2014-03-02.0
~ $ ./finish-sprint.sh 2014-03-02.1
#!/bin/bash
DRUPAL_DIR="/path/to/drupal/docroot"
TAG=$1
if [ -z $TAG ]; then
# A tag must be specified.
echo 'You must specify a tag.'
fi
# Go into the Drupal directory
cd $DRUPAL_DIR
# Start a new Git Flow release.
git flow release start $TAG -F
# Flush the cache.
drush cc all
# Export the database
drush sql-dump --gzip --result-file=../db/$TAG.sql
git add ../db/$TAG.sql
git commit -m "Exported database for $TAG"
# Finish and push the release
git flow release finish -pm $TAG $TAG
$ git flow hotfix
list
: list all hotfixesstart
: start a hotfixfinish
: finish a hotfix
~ $ git flow hotfix start {version}
~ $ git flow hotfix start 2014-03-02.2
Switched to a new branch 'hotfix/2014-03-02.2'
Summary of actions:
- A new branch 'hotfix/2014-03-02.2' was created, based on 'master'
- You are now on branch 'hotfix/2014-03-02.2'
Follow-up actions:
- Bump the version number now!
- Start committing your hot fixes
- When done, run:
git flow hotfix finish '2014-03-02.2'
~ $ git ci -am 'Updated .htaccess'
[hotfix/2014-03-02.2 6d04738] Updated .htaccess
1 file changed, 4 insertions(+), 4 deletions(-)
~ $ git flow hotfix finish 2014-03-02.2
Switched to branch 'master'
Merge made by the 'recursive' strategy.
.htaccess | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Switched to branch 'develop'
Merge made by the 'recursive' strategy.
.htaccess | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Deleted branch hotfix/2014-03-02.2 (was 6d04738).
Summary of actions:
- Latest objects have been fetched from 'origin'
- Hotfix branch has been merged into 'master'
- The hotfix was tagged '2014-03-02.2'
- Hotfix branch has been back-merged into 'develop'
- Hotfix branch 'hotfix/2014-03-02.2' has been deleted
Feedback appreciated!