gitgerrit

How to download/apply all patches from gerrit


Can you explain how to work with the same change_id in gerrit simultaneously, let's say me and someone else? We are doing all the things the same way:

git review -d change_id;
git add -A;
git commit --amend;
git review branch_name; // push changes to the same branch and change_id

For example, when I create patchset "1" and "3" and someone else patch "2" then I want to fetch "2" and still have "1" and "3" on my local. How to do this? Because when I download a change by:

git review -d change_id;

I can see only my changes "1" and "3" but not "2". Thank you.


Solution

  • If the 2nd patchset does exist, you can specify its ordinal number after the change_id,

    git review -d change_id,2
    

    As git review is a third-party command line tool, it may be unavailable. We can also use git fetch to get the patchset. Every patchset is associated with an internal ref like refs/changes/bb/aaabb/n, where aaabb is the change number or change id, bb is the result of aaabb mod 100, and n is the ordinal number of the patchset.

    # Suppose the ref is refs/changes/22/62522/2
    git fetch origin refs/changes/22/62522/2
    git checkout FETCH_HEAD
    
    # We can also create a local branch, for example 62522_2, at the same time
    git fetch origin refs/changes/22/62522/2:refs/heads/62522_2
    git checkout 62522_2