Adding dependent patches in Gerrit

Sometimes you want to push a patch that is based on another patch. Following are the steps you need to do:

Create a new branch

$ git checkout -b <your branch name>

Download the parent patch and checkout to a new branch

$ git review -d <parent patch gerrit id>

The above will result in a new branch with a name based on the parent’s patch author and the name of a topic. You may want to change it:

$ git branch -m <old branch name> <new branch name>

Add your changes and push the patch:

$ git add <file1> <file2> ..

$ git commit

$ git review

Dealing with outdated patches

Using CLI

When the parent patch is being updated you need to do the following:

$ git checkout master

Download the parent patch and checkout to a new branch

$ git review -d <parent patch gerrit id>

Download and cherry pick the child patch

$ git review -x <child id>

Upload the patch

$ git review

Change the branch name if needed:

$ git branch -m <old branch name> <new branch name>

Using GUI

If there are no conflicts you can go to your patch page and hit the ‘Rebase’ button and will update your patch automatically.

Tags: ,

Updated:

Leave a Comment