Git apply skips patches

后端 未结 3 1618
傲寒
傲寒 2021-02-12 07:32

I\'m trying to apply a patch that includes binary files with git apply but only the files are added. I tried running git apply failing.patch -v and it

相关标签:
3条回答
  • 2021-02-12 07:56

    I found out the problem by running patch -p1 < failing.patch which printed:

    can't find file to patch at input line 5

    and reminded me that I was not in the root directory.

    I can't understand why no one had asked this before and why is the verbose message not verbose.

    Also, not even the official documentation mentions skipping and possible causes.

    0 讨论(0)
  • 2021-02-12 07:59

    Suffering this issue whilst attempting to port changes across projects. git apply seems to ignore any directory names on the patch file paths, also it refuses to apply if the Index line does not match a file hash in the target repository. I had better success using these options (of which --no-index seems to be undocumented):

    git apply --verbose --no-index --directory {subdir} {patch-file} 
    
    0 讨论(0)
  • 2021-02-12 08:04

    If you use the --directory option to "git apply":

      --directory=<root>
    

    that path is RELATIVE TO THE BASE DIRECTORY (the one containing ".git"), not relative to the current working directory. You cannot use an absolute path either.

    This is completely undocumented and took me hours to discover.

    0 讨论(0)
提交回复
热议问题