How to patch on Windows?

前端 未结 4 637
一生所求
一生所求 2020-12-30 01:28

Given a (source) patch file, what\'s the easiest way to apply this patch on the source files under Windows?

A GUI tool where I can visually compare the unchanged-cha

相关标签:
4条回答
  • 2020-12-30 01:38

    Thanks to Macke, a good way to apply a patch file under Windows OS is using Git. As I understood, Git is a version control solution like SVN.

    Here is a guideline to apply a patch :

    • First of all, download the latest release of the Windows Git Edition here : GIT
    • With the cmd prompt, change directory to the patch file and files to patch
    • Now you can use the following command line :
    git apply --ignore-space-change --ignore-whitespace --whitespace=nowarn file.patch
    

    Simple isn't it ?

    Thank you Macke

    0 讨论(0)
  • 2020-12-30 01:41

    WinMerge is awesome.

    http://winmerge.org/

    0 讨论(0)
  • 2020-12-30 01:47

    Not that since Git 2.3.3 (March 2015), you can use git apply --unsafe-paths to use git apply outside a git repo.

    See commit 5244a31 by Junio C Hamano (gitster)

    "git apply" was not very careful about reading from, removing, updating and creating paths outside the working tree (under --index/--cached) or the current directory (when used as a replacement for GNU patch).

    The documentation now includes:

    --unsafe-paths:
    

    By default, a patch that affects outside the working area (either a Git controlled working tree, or the current working directory when "git apply" is used as a replacement of GNU patch) is rejected as a mistake (or a mischief).

    When git apply is used as a "better GNU patch", the user can pass the --unsafe-paths option to override this safety check.
    This option has no effect when --index or --cached is in use.

    So if you have git installed, git apply could help, even outside of any git repo.

    0 讨论(0)
  • 2020-12-30 01:56

    Patch for Windows is what you're looking for.

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