Re: git-am failed, what's next ?
From: Andy Parkins <hidden>
Date: 2016-06-15 22:42:56
On Thursday 2007 February 22 08:22, Francis Moreau wrote:
---- 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