[英]How do I pull/cherry-pick a gerrit commit/patch to a branch using a http link to the commit?
I'm trying to pull a particular gerrit commit/patch to a branch.我正在尝试将特定的 gerrit 提交/补丁拉到一个分支。 I'm not too familiar with gerrit but it seems like for usual case there are things called "patch" which are like a group of commits lumped together.我对 gerrit 不太熟悉,但在通常的情况下,似乎有一些叫做“补丁”的东西,就像一组提交在一起。 In most cases I see some steps something along the lines of在大多数情况下,我看到了一些步骤,沿东西线
Clone $git clone ssh:me@gerrit.server.com/potato
Checkout $git checkout fried_branch
Fetch $git fetch ssh:me@gerrit.server.com/potato refs/changes/01/23456/7
Cherry-pick $git cherry-pick FETCH_HEAD
Pull $git pull ssh:me@gerrit.server.com/potato refs/change/01/23456/7
where the refs/changes is used to find the commit/patches.其中 refs/changes 用于查找提交/补丁。 Instead I am given a http link to gerrit commit/patch along the line of相反,我得到了一个指向 gerrit commit/patch 的 http 链接
http://gerrit.server.com:8080/#/c/12345/
I assume I need to change the Fetch and pull step of the clone, checkout, fetch, cherry-pick, pull but I'm not sure how to do this this with the http link instead of refs.我假设我需要更改克隆、结帐、提取、挑选、提取的提取和提取步骤,但我不确定如何使用 http 链接而不是 refs 执行此操作。 How do I change the step to work with http?如何更改使用 http 的步骤?
A Gerrit change is a single commit, but there can be more than one version of the commit in the same change; Gerrit更改是一次提交,但在同一个更改中可以有多个版本的提交; each version is called a patch set .每个版本称为一个补丁集。
You don't fetch a change from Gerrit;您不会从 Gerrit 获取更改; you actually fetch a particular patch set for a change.您实际上获取了一个特定的补丁集以进行更改。 The URL you need to use will include not just the change number, but the patch set number too.您需要使用的 URL 不仅包括更改编号,还包括补丁集编号。
The link you've been given:你得到的链接:
http://gerrit.server.com:8080/#/c/12345/ http://gerrit.server.com:8080/#/c/12345/
tells you the change number (12345), but doesn't tell you which patch set number to use.告诉您更改编号 (12345),但不会告诉您要使用哪个补丁集编号。 In fact it doesn't even tell you which repository the change is for (a Gerrit server can host many repositories).事实上,它甚至没有告诉您更改是针对哪个存储库(Gerrit 服务器可以托管许多存储库)。
If you go to the URL in your browser, you should be taken to the latest patch set for the change.如果您转到浏览器中的 URL,您应该会看到更改的最新补丁集。 You should see Download ⯆ in the top right corner.您应该会在右上角看到下载 ⯆ 。 Look for the "Cherry Pick" line, which gives you two commands: a git fetch
command to fetch the patch set (ie commit), and a git cherry-pick
command to cherry-pick the fetched commit to whatever branch you're currently on.查找“Cherry Pick”行,它为您提供两个命令:一个用于获取补丁集(即提交)的git fetch
命令,以及一个用于将获取的提交挑选到您当前所在的任何分支的git cherry-pick
命令在。
Here's an example from the Eclipse Gerrit.这是 Eclipse Gerrit 中的一个示例。 This change:这个变化:
https://git.eclipse.org/r/#/c/154809/ https://git.eclipse.org/r/#/c/154809/
is for the jdt/eclipse.jdt.debug repository, and has 3 patch sets at the time of writing.用于 jdt/eclipse.jdt.debug 存储库,在撰写本文时有 3 个补丁集。 This is a link to patch set 3:这是补丁集 3 的链接:
https://git.eclipse.org/r/#/c/154809/3 https://git.eclipse.org/r/#/c/154809/3
In the top right, the cherry pick commands are:在右上角,樱桃选择命令是:
git fetch https://git.eclipse.org/r/jdt/eclipse.jdt.debug refs/changes/09/154809/3 && git cherry-pick FETCH_HEAD
In the git fetch
command, 09
are the last two digits of the change number, 154809
is the full change number, and 3
is the patch set number.在git fetch
命令中, 09
是更改号的后两位, 154809
是完整的更改号, 3
是补丁集号。
I find a walk around for this, but need to use git-review.我为此四处走动,但需要使用 git-review。 first you just need to get the last part of the url http://gerrit.server.com:8080/#/c/12345/ .首先,您只需要获取 url http://gerrit.server.com:8080/#/c/12345/的最后一部分。
git review -d 12345
git checkout master # switch to your work branch
git cherry-pick FETCH_HEAD
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.