git 你如何应用从gerrit下载的补丁文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37758202/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:02:59  来源:igfitidea点击:

How do you apply patch file downloaded from gerrit?

gitgerrit

提问by Fantastic Mr Fox

In Gerrit, under the download section for a change, there is a section that allows you to download the Patch-File:

在 Gerrit 中,在更改的下载部分下,有一个部分允许您下载补丁文件:

enter image description here

在此处输入图片说明

Using git applyresults in:

使用git apply结果:

$ git apply 441eb56b.diff.base64
fatal: unrecognized input

What command do I use to apply this patch?

我用什么命令来应用这个补丁?

回答by pestophagous

base64 --decode c6a9dcdb.diff.base64 > c6a9dcdb.diff
git apply c6a9dcdb.diff

(Replace c6a9dcdb with whatever abbreviated commit hash Gerrit gave you.)

(用 Gerrit 给你的任何缩写提交哈希替换 c6a9dcdb。)

回答by Marcelo ávila de Oliveira

This is a base64 encode file (see here). You need to decode the file first (see here). I think it's easier to use the Cherry Pick method instead.

这是一个 base64 编码文件(请参阅此处)。您需要先解码文件(请参阅此处)。我认为使用 Cherry Pick 方法更容易。

回答by ElpieKay

Here are possible solutions.

以下是可能的解决方案。

  1. Just copy and paste Cherry Pick's command.

  2. Just copy and paste Checkout's command, and run git format-patch -1to create the patch which can be used in git amor git apply. You could also run git diff HEAD^..HEAD > xxx.patchto generate a patch, wchich can be used in git apply.

  3. Download the diff.zip, unzip it, git applyit.

  4. Download the diff.base64, decode it, git applyit.

  5. Run the git fetchpart in Checkoutor Cherry Pickcommands, use git merge,git rebase,git cherry-pickor any command that can manipulates commits to apply the patch you need.

  6. If the patch is to be applied to another branch which can be found in Gerrit, use cherry-pickbutton to do it.

  1. 只需复制和粘贴Cherry Pick的命令。

  2. 只需复制并粘贴Checkout的命令,然后运行git format-patch -1即可创建可在git am或 中使用的补丁git apply。您也可以运行git diff HEAD^..HEAD > xxx.patch以生成补丁,可以在git apply.

  3. 下载diff.zip,解压,git apply就可以了。

  4. 下载diff.base64,解码它,git apply它。

  5. 运行git fetch部分CheckoutCherry Pick命令,使用git mergegit rebasegit cherry-pick或可以操纵提交申请你所需要的补丁的任何命令。

  6. 如果要将补丁应用到 Gerrit 中可以找到的另一个分支,请使用cherry-pick按钮来完成。