Gerrit workflow - push single commit to topic branch

被刻印的时光 ゝ 提交于 2019-12-10 14:37:35

问题


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?


回答1:


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



回答2:


you can do

git push origin :master

but first you may need to do a rebase to take care of the related commits using

git rebase -i

For more information have a look here http://blog.dennisrobinson.name/push-only-one-commit-with-git/



来源:https://stackoverflow.com/questions/17785416/gerrit-workflow-push-single-commit-to-topic-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!