Reputation: 79605
I'm trying to apply a patch, and git apply patch doesn't give me any errors:
sashoalm@SASHOALM-PC /c/Workspace/tesseract-git/api (master)
$ git apply ../../commit-d0d9477
sashoalm@SASHOALM-PC /c/Workspace/tesseract-git/api (master)
$
As you can see, no error messages are given. But when I open the history, nothing is committed, and the index is empty. It's as if I haven't issued the git apply
command.
I'm at a loss how to troubleshoot this, since there no errors to Google.
Edit: I forgot to say, but I'm trying to transplant my patches from a repository of Tesseract, where I got the source without version control, created my own empty git repo, and made some commits. Later I cloned the Tesseract repository using git svn
, and now I'm trying to move my patches there.
Upvotes: 48
Views: 26015
Reputation: 35785
Run git apply
with -v
option to see more information from git.
-v, --verbose Report progress to stderr. By default, only a message about the current patch being applied will be printed. This option will cause additional information to be reported.
In my case the patch was silently skipped because of wrong directory from where git apply
was run.
Upvotes: 2
Reputation: 1313
Further to B_'s answer, you might think that using git diff --no-prefix
would mean you don't need to use the -p flag on patch
. It appears you would be wrong, at least in the versin of patch
I have here (2.5), no -p flag is not the same as -p0. -p0 works.
Upvotes: 2
Reputation: 2254
I found this while googling for the issue: http://data.agaric.com/git-apply-does-not-work-from-within-local-checkout-unrelated-git-repository
git apply
will fail to do anything when used within a local checkout of a git repository (other than the one for the project the patch is made for), such as if you are patching a module that is within a site that is in Git version control.Use
patch -p1 < path/file.patch
instead.
Upvotes: 92