Git workflow and Gerrit

Ivo picture Ivo · Dec 6, 2011 · Viewed 8.6k times · Source

I am trying to implement a 'git-flow' kind of workflow using Gerrit but I can't seem to figure out the last piece of the puzzle.

There are two preconditions to my problem:

  • Gerrit will only perform merging to one branch
  • I do not allow merge commits to be pushed to Gerrit. The merging has to be done by Gerrit after the changes are approved

What I want to solve is the following. Consider this git situation:

Master 0 
        \
         \
Develop   0-----0-----0-----0

There is a master branch with one commit and a develop branch which is forked from master with several additional commits. After a while the develop branch is merged back into master to create the next production release. The developers work with topic branches from develop and with strict rebasing. Their commits are always rebased on top of the latest upstream develop before pushing. This should result in linear history and only fast forward commits.

Now suppose someone creates a hotfix branch from master and merges back to master:

Master 0--------0 HF 
        \
         \
Develop   0-----0-----0-----0

This commit is now only merged to the master branch but the developers need this commit in their develop branch to incorporate the bugfix in their changes. Normally you would merge the master branch to develop the develop branch but considering my preconditions this is not possible as it would create a local merge commit.

My question is: how do I incorporate the new commits from the master branch into the local develop branch so that any new changes by the devs will contain the bugfix? Ideally I would modify my script to first apply the bugfix changes to the local develop branch (merging but without a merge commit) and then rebase the dev's commits and push. This way the bugfix will be automatically added to their new changes and will be seen as such, as part of their new commits, not a seperate commit.

I've been thinking about possible solutions:

I hope my question is clear. Please let me know if it needs further clarification. I know I'm being pretty rigid with my workflow, but it would be ideal in combination with Gerrit. If it can't be done then I will probably allow merge commits...

Answer

Ivo picture Ivo · Dec 9, 2011

After considering the options I have decided to abandon this method. It seems to me that Gerrit is targeted at single integration branch development for the most part.

When changes need to be merged to two branches (eg. a hotfix that needs to go to master and develop) it makes you jump through all kinds of hoops which amount to extra work/reviewing. I've decided to stick to one branch.

I think that the Git flow model doesn't really suit in the Gerrit design. If other people have integrated Gerrit with Git flow I would love to hear about their methods.