User:Milimetric (WMF)/GitFlowGerrit
This is a page where I'm tracking what we'd like to be able to do with git flow. The big problem is that it might mess up gerrit's expectations so this is a work in progress to make sure that doesn't happen.
Working on feature Test1
$ git flow feature start Test1 $ echo "test 1" >> test1.txt && git add . $ git commit -a -m "test 1" $ echo "test 2" >> test2.txt && git add . $ git commit -a -m "test 2" $ git flow feature finish Test1
And working on feature Test2 (I tried these in series but the same idea should apply in parallel)
$ git flow feature start Test2 $ echo "test 3" >> test3.txt && git add . $ git commit -a -m "test 3" $ echo "test 4" >> test4.txt && git add . $ git commit -a -m "test 4" $ git flow feature finish Test2
Once done, we'd like to get a release branch and git review it.
$ git flow release start GerritTest $ git review
So far so good. The tricky part starts here. If one of your commits (4 real and 2 merges) from above is rejected in Gerrit, you'll have to amend it and resubmit it. The closest we got so far is with rebase but that causes the merge commits to get lost so the gerrit patchset can't go forward. One idea would be to rebase before git review, that way the merge commits don't get pushed in the first place. This would make the reviewer's job easier.
Outside of the problem above, the other trick is figuring out what "2" is in your case. I used trial and error and just aborted the rebase if it didn't have the set of changes I wanted.
# ... find what HEAD~X will get you the same set of commits that was originally submitted to gerrit $ git rebase -i HEAD~2 # ... find your commit and change (pick) to (edit) # ... fix the problem your reviewer found $ git add . $ git commit -a --amend # ... write a message describing your fix $ git rebase --continue $ git review
Assuming everything's ok, the last part's easy
$ git flow release finish GerritTest
Note: this | Stack Overflow advice, didn't work because rebase is a lot harder across the branches that git flow creates.