When applying a patch is there any way to resolve conflicts?

前端 未结 4 1662
遇见更好的自我
遇见更好的自我 2020-12-22 15:34

I am on windows.

For various reasons we have multiple git instances of different svn branches.

Many times I want to fix an issue in repository A, generate

相关标签:
4条回答
  • 2020-12-22 16:18

    My approach is:

    • Create an "Integration"-Branch where the files are identical
    • Apply the patch to this Integration-Branch
    • Merge or rebase it to master (don't know if rebase is useful here, because I don't know what will happen when applying further patches)
    0 讨论(0)
  • 2020-12-22 16:19

    To generate your patch do the following:

    git format-patch --stdout first_commit^..last_commit > changes.patch
    

    Now when you are ready to apply the patches:

    git am -3 < changes.patch
    

    the -3 will do a three-way merge if there are conflicts. At this point you can do a git mergetool if you want to go to a gui or just manually merge the files using vim (the standard <<<<<<, ||||||, >>>>>> conflict resolution).

    0 讨论(0)
  • 2020-12-22 16:31

    If you are frequently running into the same conflict set when applying patches, rebasing or merging then you can use git rerere (reuse recorded resolution) function. This allows you to pre-define how conflicts should be resolved based on how you resolved them in the past. See http://git-scm.com/blog/2010/03/08/rerere.html for details of how this works.

    0 讨论(0)
  • 2020-12-22 16:34

    TortoiseGit has a merge feature that can open patch files.

    There's a picture of it here.

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