Tell git not to merge binary files but to choose

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 temporary branch, and commit the local changed binary files, and merge them back after the pull with recursive theirs strategy. — Too much work.

  • Why is the git index file binary?
  • Managing large binary files with git
  • Can't push to Git, due to binary files
  • git: keep only the latest version of a specific file
  • Large files extension for git
  • Add binary distribution to github's download link
  • Is there a way to tell git, not to attempt merging binary files and ask me which one of these versions to use.

  • Pre commit hook to check PHP code coverage and code sniffer for Symfony
  • missing folder in repository after git add
  • Git Conflict — Showing False Positive
  • How to track but not stage and how to unstage but not untrack?
  • Restoring git directory while preserving history
  • How do I export a git log to a text file?
  • One Solution collect form web for “Tell git not to merge binary files but to choose”

    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 "always keep their during merge"
    git config merge.keepTheir.driver " %O %A %B"


    git config "always keep mine during merge"
    git config merge.keepMine.driver " %O %A %B"
    [merge "keepMine"]
            name = always keep mine during merge
            driver = %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.

    Git Baby is a git and github fan, let's start git clone.