DEV Community


Custom Git Workflows with the latest git-reflow

Valentino Stoll
Originally published at on ・2 min read

New git-reflow release: Custom Git Workflows

This release includes the culmination of several years of effort to allow you to customize our process to suit your specific needs. We’ve dropped a heavy dependency (gli) and introduced a pretty slick DSL for creating new git commands or override our existing ones.

I am really excited to announce the released version 0.9.0 of the git_reflow gem!

Custom Workflows

Git-reflow’s default process isn’t meant to fit every team, which is why we’ve introduced Workflows.

We’ve introduced a special file that can contain customizations to the default process. With this, you can:

  1. Add hooks to be run before, or after any command
  2. Use one of our pre-configured workflows as a basis for your own
  3. Override any of the default commands
  4. Create new commands

Here is an example showcasing all the various ways you can customize the process:

# Use a pre-defined workflow
use "FlatMergeWorkflow"

# Do something before the `start` command
before :start do
  say "Booya! Started this bad girl."

# Do something after the `deliver` command
after :deliver do
  run "say 'Well done!'"

# Override the `start` command to auto-name feature branches
command :start, arguments: { feature_branch: nil }, flags: { base: 'dev' }, switches: { loud: false } do |**params|
  base_branch    = params[:base]
  feature_branch = params[:feature_branch] || "feature-#{"%Y-%m-%d")}"

  run_command_with_label "git checkout #{base_branch}"
  run_command_with_label "git pull origin #{base_branch}"
  run_command_with_label "git push origin #{base_branch}:refs/heads/#{feature_branch}"
  run_command_with_label "git checkout --track -b #{feature_branch} origin/#{feature_branch}"

# Create a new command
# Makes `git reflow boom` available in the command line.
command :boom do
  GitReflow.say "Boom."

You can define a unique workflow for each of your projects simply by placing it in the root of your project, or by setting a special reflow.workflow git-config setting with the full path of the file.

The block that you pass to each of the git-reflow reserved commands (use, before, after, command) are executed in the context of our Core workflow class. This gives you the ability to use any code available to the GitReflow module. We encourage you to use as much of GitReflow’s tooling as possible so that you can take full advantage of getting the current branch name, logging, exception-handling, colorized output, and several other features that are baked into GitReflow’s internals. For a full list of what’s available, see Available Workflow Helpers on our wiki.

Ramping Up To 1.0

With the re-workings of Workflows in place, we’re getting ready for our first major release! Our current plans are to focus on:

  1. Introduce Pivotal Tracker & Trello workflows
  2. Add GitLab integration
  3. Add an Open Source workflow

We’re looking forward to some exciting times! We’d love to hear all the interesting ways you use these new workflows, so please don’t hesitate to let us know.

Happy hacking!

Discussion (0)