Tell git not to merge binary files but to choose

前端 未结 1 1656
无人及你
无人及你 2020-11-30 06:28

When the binary files, swfs, jars and flvs are changed locally, and I try to pull in changes, git tries to merge them and reports conflict.

And then, I branch to a t

相关标签:
1条回答
  • 2020-11-30 06:52

    You could set up a merge drive in a .gitattributes file (only for a given subtree, only for some file types)

    See this question for instance (or this one).

    # choose the name of the merge driver to be use for all jar files
    echo *.jar merge=keepTheir > dirWithJarFiles\.gitattributes
    

    Declare your merge driver in the config of the Git repo:

    git config merge.keepTheir.name "always keep their during merge"
    git config merge.keepTheir.driver "keepTheir.sh %O %A %B"
    

    or

    git config merge.keepMine.name "always keep mine during merge"
    git config merge.keepMine.driver "keepMine.sh %O %A %B"
    [merge "keepMine"]
            name = always keep mine during merge
            driver = keepMine.sh %O %A %B
    

    The example I give don't ask you for a choice but will always keep "mine" (or "yours") version when merging.
    But you could adapt the script executed by this merge driver to ask you a question, and then apply your choice to all merges.

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