Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git workflow and Gerrit

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:

  • Cherry picking the commit to the develop branch. I believe this will always result in a duplicate commit when develop is merged with master the next time. Is there any way around this?
  • Rebasing as described here: http://davitenio.wordpress.com/2008/09/27/git-merge-after-git-cherry-pick-avoiding-duplicate-commits/ . This probably causes problems since the develop branch is published, or won't it?

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...

like image 346
Ivo Avatar asked Dec 06 '11 19:12

Ivo


People also ask

What is difference between Git and Gerrit?

In GitHub, you would push your branch to the remote, go to the Web UI and create a pull request. In Gerrit, you need to push your commit (or the series of changes/commits) to the remote first, since you usually develop in a local branch only.

How does Git work with Gerrit?

Gerrit is a web-based code review tool, which is integrated with Git and built on top of Git version control system (helps developers to work together and maintain the history of their work). It allows merging changes to Git repository when you are done with the code reviews.

What is Gerrit tool?

Gerrit (/ˈɡɛrɪt/ GERR-it) is a free, web-based team code collaboration tool. Software developers in a team can review each other's modifications on their source code using a Web browser and approve or reject those changes. It integrates closely with Git, a distributed version control system.


1 Answers

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.

like image 148
Ivo Avatar answered Oct 12 '22 12:10

Ivo