How do you have Git ignore merge conflicts for a directory?
How do you force git to always accept files from a specific branch?
Look no further.
I have all of my project files in a git repo, including my libraries. Some libraries must compile and build binaries dependent on the OS, in my example pyCrypto.
That means I have a development branch for local development on my Mac, and a production branch that has the correct pyCrypto binaries for the production server.
However, every time I try to merge changes from my development branch, I’d get conflicts (naturally) since the binaries are different between the two packages.
I’ve solved my problem by forcing git to NOT merge the Crypto folder at all
I set up a git merge driver that does nothing at all, and set all files in the Crypto folder to use this driver.
All of this info comes from a stack question here http://stackoverflow.com/questions/928646/how-do-i-tell-git-to-always-select-my-local-version-for-conflicted-merges-on-a-sp/930495#930495
Step 1: create a special merge rule in your repositories .git/config file
[merge "keepmine"] name = dont_merge_selected_files driver = echo %O %A %B
Step 2: navigate to the folder you want never merged from outside branches, and create a .gitattributes file where you specify all files to use the merge driver “keepmine” defined in step 1
commit your changes, and try merging! The conflicts in the folder with .gitattributes will not register and leave the original files intact. If you want the other way around, where your branch is always overwritten by a merge, take a look at the stack post above.
It says to set up a merge driver as
keepMine.sh %O %A %B
and in your keepMine.sh
cp -f $3 $2. return 0
where 0 is the exit code of “resolved”.
This saves my world.