如何从Gerrit中拖拉一个给定的补丁集? [英] How to git-pull a given patch set from Gerrit?

查看:120
本文介绍了如何从Gerrit中拖拉一个给定的补丁集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Gerrit(Code Review)时,我经常需要获取给定补丁集的副本以进行测试或验证。显而易见的方法是通过Gerrit Web界面下载档案或补丁文件,并手动将其应用到我的本地源。

When working with Gerrit (Code Review), I often need to get a copy of a given patch set for testing or validation purpose. The obvious and easiest way is to download the archive or the patch file through the Gerrit Web interface and manually apply it to my local source.

虽然上述步骤非常简单并满足我的需求,在最好的世界中,我希望修补程序集在我的本地Git中显示为提交。

While the above steps are pretty straightforward and fulfill my needs, in the best world I would like to have the patch set appearing as a commit in my local Git.

我环顾四周,没有找到解决方案。我发现了一些稀疏信息,一旦编译出来就给出了以下解决方案。

I was looking around and didn't find the solution. I found some sparse info that once compiled together gives the following solution.

假设您想要拉取Gerrit变更1222的补丁集2:

Say that you want to pull the patch set 2 of the Gerrit change 1222:

找到我们感兴趣的远程引用:

Find the remote refs we are interested in:

$ git ls-remote | grep 1220
From http://something.com:8081/MyProject
e2e0212a59240ac5cd7c11220c35542523f44b59        refs/changes/13/713/1
b8c4dceea5eaf1bad711b0ea6938c80ec932726a        refs/changes/20/1220/1
6f20c182ec7f54a2aa9e8f6188a0eef1b0790df4        refs/changes/20/1220/2
ed94a98386d224ce3d86004ce99f61220905a077        refs/changes/22/1222/1

拉出参考:

git pull origin refs/changes/20/1220/2

这将创建一个Git提交点,最终可以重新绑定:

This will create a Git commit point that you could eventually rebase:

git rebase


推荐答案

此功能在Gerrit用户界面中是标准配置。

This feature is standard in the Gerrit UI.

在修补程序UI的右上角,单击下载,您将看到如下所示的内容:

On the top right of the UI for a patch, click Download, and you will see something like:

当您正在浏览您要转至的补丁时下载部分并复制命令行命令来检出补丁集,例如:

When you are navigating the patches you go to the download section and copy the command line command for checking out the patch set, for example like this:

git fetch https://gerrit.googlesource.com/gerrit refs/changes/03/64403/2 && git checkout FETCH_HEAD

然后,我通常会创建一个分支,评论编号和patchset作为名称

Then I normally create a branch with the review number and patchset as name

git checkout -b b64403-2

在这里,您可以正常工作并提交您的更改或对此更改进行修改或重新整理。

For here you can work normally and commit your changes or cherry-pick/rebase your changes on this change.

完成对r64403的审核后您的代码可以合并,或者当提交另一个补丁集时,您将需要再次执行相同的操作。

Once the review of r64403 is done your code can be merged or when there is another patchset submitted you will need to do the same thing again.

如果您没有看到选项将选项下载到 Checkout Cherry Pick 您需要编辑 gerrit.config ,像这样:

If you do not see the options to download the option to Checkout or Cherry Pick you need to edit the gerrit.config, something like this:

[download]
    scheme = ssh
    command = checkout
    command = cherry_pick

更多详细信息可以在 Gerrit文档

更新:
As barryku 正确指出,在更高版本中,您需要下载downloads-commands插件。这可以在初始设置期间完成,也可以使用以下命令完成:

Update: As barryku correctly points out, in the later version you need to download the downloads-commands plugin. This can be done during the initial setup or by using the following command:

java -jar gerrit-2.11.4.war init -d review_site --batch --install-plugin download-commands

这篇关于如何从Gerrit中拖拉一个给定的补丁集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆