Git apply a patch to the working directory

后端 未结 3 755
情深已故
情深已故 2021-02-04 00:36

I have a patch that contains a lot of changes that I would like to split into multiple commits and potentially modify some of the changes.

I want to apply this patch to

相关标签:
3条回答
  • 2021-02-04 01:20

    Try this command line

    git am < patchname.patch
    
    0 讨论(0)
  • 2021-02-04 01:23

    You can use git apply which applies a patch:

    git apply < patchname.patch
    

    This does not create any commits. In fact, without any options the git apply command doesn't even need to have a Git repository. It just applies patches to files.

    0 讨论(0)
  • 2021-02-04 01:34

    You can use a patch command, e.g.:

    patch -p1 < path/file.patch
    

    When using patch command, it will usually auto-detect the format. This is useful when you're trying to apply patch to the working directory which isn't a local checkout of the project you wish to patch.

    Otherwise use git apply if your patch was created specifically for the project, otherwise it will fail to do anything when used within a local checkout of a git repository.

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