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.

Is there a way to tell git, not to attempt merging binary files and ask me which one of these versions to use.

  • How can I drop a branch from a mulitple branch merger in git?
  • Merging a branch on a not updated master
  • git merge: PR on master “messed” up my test branch, how do I fix it?
  • How do I “merge” two YAML text files?
  • After a git pull there a lot of unrelated modifications in the staging area
  • Script to merge 2 git branches automatically?
  • Any way to automatically merge approved nonconflicting Gitorious merge request?
  • Merging: Hg/Git vs. SVN
  • 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.