Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gerrit workflow - push single commit to topic branch

I want to push a single commit to Gerrit without affecting other commits in the same topic branch. Unfortunately I don't have a test instance of Gerrit to experiment with.

Scenario: I have contributed a topic branch to the project, which is in review, and other developers have updated parts of it. Now I wish to make changes on top of their updates.

To do this I pull the changes by the other developer in the commit I wish to edit, do an interactive rebase locally to make my own changes, then push to Gerrit, making sure the Change-Id is still the same. This adds a new version of the file to the patchset for review.

Problem: When I tried to push a single commit to Gerrit, the other commits in the topic-branch were also pushed, overwriting changes by other developers.

Here is the syntax I used:

git push gerrit 3089c9f56542461dce738a9aa17bb743ed36e038:refs/publish/master/my-topic-branch

I presume that the other commits in the topic-branch were also pushed because of dependencies created by Gerrit.

Would this approach work instead, leaving out the topic branch title?:

git push gerrit 3089c9f56542461dce738a9aa17bb743ed36e038:refs/publish/master

I tried this approach successfully previously, pushing to the specific changeset:

git push gerrit a95cc0dcd7a8fd3e70b1243aa466a96de08ae731:refs/changes/12345

However, in trying this again I am now getting an unpack error:

error: unpack failed: error Missing tree 9172313b907b160d15e260d5f7d51689f467b858

Related question: When I pull the other developers' changes from Gerrit, how can I make sure that I have pulled all the files contributed in the topic-branch? If I select the topmost change in Gerrit in the topic-branch, and use the pull command stated in the web ui, it seems that some of the files in the topic-branch are updated locally, but not all. Do I need to go through every single commit in the topic-branch and issue the relevant pull command?

like image 823
Lemmy Avatar asked Nov 12 '22 01:11

Lemmy


1 Answers

I don't know the commands of hand but it would be something like this:

  1. Make new branch of the topic branch
  2. Merge the commit you want to add to the topic branch into this new branch
  3. Push the newly created merge to gerrit
like image 158
user2466013 Avatar answered Dec 09 '22 11:12

user2466013