Error in running 'git apply'

后端 未结 3 1339
谎友^
谎友^ 2021-02-08 02:26

Can you please tell me how can I resolve the \'patch does not apply\' error when I try to \'git apply-patch\'?

$ git apply 0001-my.patch
error: patch failed:test         


        
3条回答
  •  再見小時候
    2021-02-08 03:06

    You can try a:

    git am -3
    

    When the patch does not apply cleanly, fall back on 3-way merge (git am doc)


    qneill mentions in the comments that git apply now have a --3way option:

    you can now apply your patches without having to reduce context.
    As it will leave the conflicted halves in the index and let you manually resolve conflicts in the working tree, "--3way" implies "--index", and cannot be used with "--cached" or "--reject".

    You can see it in the git1.7.12 release note (August 2012, a bit less than 3 years after the original question)

    "git apply" learned to wiggle the base version and perform three-way merge when a patch does not exactly apply to the version you have.

提交回复
热议问题