19

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

enter image description here

Using git apply results in:

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

What command do I use to apply this patch?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175

3 Answers3

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

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

pestophagous
  • 4,069
  • 3
  • 33
  • 42
8

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 -1 to create the patch which can be used in git am or git apply. You could also run git diff HEAD^..HEAD > xxx.patch to generate a patch, which can be used in git apply.

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

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

  5. Run the git fetch part in Checkout or Cherry Pick commands, use git merge,git rebase,git cherry-pick or 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-pick button to do it.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53
6

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.

Community
  • 1
  • 1
  • Yeah, i ended up cherry picking the change. But that is very interesting about the patch data. – Fantastic Mr Fox Jun 13 '16 at 16:29
  • You could of course pipe the base64 decode result into `git apply`. But anyhow, the download-patch functionality appears to be primarily for people who don't have a checked-out git repo availabe, in which case the cherry-pick is of course easier. See [bugtracker](https://bugs.chromium.org/p/gerrit/issues/detail?id=302). What I miss is a patch download that really downloads only the diff between patchsets so that a cherry-pick won't interfere with my changes to the same patchset. – sebkraemer Feb 05 '18 at 10:12