简体   繁体   English

如何使用指向提交的 http 链接将 gerrit 提交/补丁提取/樱桃选择到分支?

[英]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.

相关问题 我如何挑选来自github的未合并提交? - How do I cherry-pick an unmerged commit from github? 我怎么能 git cherry-pick 从分支 A 到分支 B 但我在分支主机中的提交? - how can I git cherry-pick a commit from branch A to branch B but I am in branch master? GIT:如何使用cherry-pick在两个分支中提交 - GIT: how to commit in two branches using cherry-pick 如何合并/挑选单个提交 - How to merge/cherry-pick a single commit 在另一个分支中检测提交 diff/patch/hunk,类似于 cherry-pick 的方式 - Detect a commit diff/patch/hunk in another branch similar to the way cherry-pick does 从 Master 到 Branch(Master 提交 --> Branch),cherry-pick 是否有效? - Is cherry-pick works from Master to Branch (Master commit --> Branch)? 樱桃选择此提交-但将补丁应用于其他名称的文件 - Cherry-pick this commit - but apply the patch to a differently-named file 吉特:我该如何撤消导致冲突的樱桃挑剔-不提交? - Git: How do I undo a cherry-pick --no-commit that generated conflicts? 如何使用cherry-pick或任何其他方法将提交(包含2-3个文件)从一个分支移动到另一个分支 - How to Move commit(contains 2-3 files) from one branch to another branch using cherry-pick or any other method 如果我从一个分支中挑选一个提交,然后合并整个分支,那么 git 历史会发生什么? - If I cherry-pick a commit from a branch and then merge the whole branch later what happens to the git history?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM