git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-am failed, what's next ?

From
APAndy Parkins <andyparkins@gmail.com>
Date
Feb 22, 2007, 08:48 UTC
Message-ID
<200702220848.06637.andyparkins@gmail.com>
In-Reply-To
<38b2ab8a0702220022wab25519hbb57629934e7f104@mail.gmail.com>
On Thursday 2007 February 22 08:22, Francis Moreau wrote:
Show 8 quoted lines
> ----
> error: patch failed: foo:1
> error: foo: patch does not apply
>
> Patch failed at 0001.
> When you have resolved this problem run "git-am --resolved".
> If you would prefer to skip this patch, instead run "git-am --skip".
> ---

I've often wished for more information from git-am (or more correctly, git-apply). However, you can sometimes get what you need to know another way.

 * First, make sure that your current tree is checked in so you can get back
   to it easily.  Maybe switch to a new temporary branch to make it easy to
   return to your current point.
 * Then run git-am to get the number of the failing patch, in your example 
   it's "0001"
 * Now, try and apply the patch manually, but turn on verbose and reject in 
   git-apply
    $ git-apply --verbose --reject .dotest/0001
   This is the only way I've found to get git to tell you which hunk of the
   patch is being rejected.  Unfortunately, it will also leave you with that
   patch partially applied.
 * Sometimes the partially applied patch will be enough.  Have a look at the
   *.rej files that have been created and see if you can resolve the conflict
   by hand - you could apply the patch by hand if it's only a small hunk.
   If you do this, you can then continue with the git-am by first updating the 
   index (git-add somefile.c), then running git-am --resolved
 * If you wanted to you could just skip that patch with "git-am --skip"
 * If you wish you hadn't started any of this you can obviously use git-reset 
   to get you back to the start point.
Hope that helps.
Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Previous: Francis MoreauNext: Francis Moreau
Message 2 of 10 in “git-am failed, what's next ?”
  1. Francis MoreauFeb 22, 2007
  2. Andy ParkinsFeb 22, 2007
  3. Francis MoreauFeb 22, 2007
  4. Junio C HamanoFeb 22, 2007
  5. Francis MoreauFeb 22, 2007
  6. Junio C HamanoFeb 22, 2007
  7. Francis MoreauFeb 22, 2007
  8. Andy ParkinsFeb 22, 2007
  9. Junio C HamanoFeb 22, 2007
  10. Johannes SchindelinFeb 22, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.