-
-
Notifications
You must be signed in to change notification settings - Fork 43
[archived] Gerrit: use cases
Note: Now that the new architecture code has been added in our repo, we are back to the patches sent via e-mails, with short iterations.
The workflow is basically the same as before but instead of using git send-email
, git review
will be used.
You are starting a new feature:
git checkout -b my_branch for-review
(...) # work here
git add -u <...>
git commit -sm "foo" # Change-Id has been added
(...) # create more commits if needed
git review for-review # new Change created, by default the target branch is `master` if you didn't set a .gitreview file
You previously send a first version of your patch-set but you now want to update these patches:
git checkout my_branch
git commit --amend # or `git rebase -i <...>` as before
git review for-review # Changes have been updated, by default the target branch is `master` if you didn't set a .gitreview file
To download a change created or updated by someone else, e.g. the ID 436386:
git review -d 436386
If you need to rebase your work and send a new version, ideally and to help reviewers, it is better to do that in two phases not to compare two versions with two different bases:
git checkout my_branch
# step 1: rebasing the work
git rebase origin/for-review
git review --work-in-progress # change will be marked as WIP and "rebased"
# step 2: doing extra modifications
git commit --amend # or `git rebase -i <...>` as before
git review --ready # WIP mark will be removed
There are two cases here: either these other changes are already in our Gerrit or changes have been published somewhere else (e.g. RFC for net-next)
Simply create your new commits like you would on top of for-review
but download the other changes first:
git review -d 436386 # instead of something like: git checkout -b my_branch for-review
(...) # work here
git commit -s # create more commits if needed
git review for-review # new Change created on top of Change 436386, by default the target branch is `master` if you didn't set a .gitreview file
The easiest way is to also add these other commits in your development branch you publish in Gerrit:
git am <patch> # or cherry-pick or pull ...
git commit --amend --no-edit # to add the Change-Id for Gerrit
(...) # work here
git commit -s # create more commits if needed
git review for-review # new Changes created including the ones from other people
Note: if you have a bunch of commits where the Change-Id is missing, you can use this command:
cp .git/hooks/commit-msg /tmp
git filter-branch -f --msg-filter 'git log -1 --pretty=%B $GIT_COMMIT > msg.txt; /tmp/commit-msg msg.txt; cat msg.txt; rm msg.txt' <LAST_COMMIT_IN_A_PUBLISHED_BRANCH>..HEAD
Note: it is also possible to use the --private
mode with Gerrit