Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git apply patch fails silently (no errors but nothing happens)

Tags:

git

patch

msysgit

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.

like image 216
sashoalm Avatar asked Jul 18 '14 09:07

sashoalm


People also ask

Why is git apply skipping patch?

A patch is usually skipped when the changes it contains were already applied in the past. There are many possible reasons for this: a merge, a cherry-pick, changes operated manually or using another patch etc.

How do patches work in Git?

GIT patch or GIT diff is used to share the changes made by you to others without pushing it to main branch of the repository. This way other people can check your changes from the GIT patch file you made and suggest the necessary corrections.


1 Answers

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.

like image 64
B_. Avatar answered Sep 28 '22 01:09

B_.