Possible Duplicate:
Locking binary files using git version control system
I am committing a file which should never be merged, but overwritten (perhaps with a warning) when other people pull. Is there a way of accomplishing this?
It's a little unclear what your actual situation is. The first question you should ask yourself is whether the file actually needs to be tracked - unmergeable files are often derived files, as you suggest in the comments, and therefore don't need to (and shouldn't) be tracked.
If you really do need to track it, is it a binary file? Git doesn't try to merge binary files - they always show up as merge conflicts. Git is good about detecting binary files, so in this case, you're probably safe. If it's not a binary file, then you still force Git to deal with it appropriately. In a .gitattributes
file, add something like:
path/to/file merge=binary
This will direct it to treat it as a binary file for purposes of merging. You could also, if you wanted, define a custom merge driver. Use merge=my_merge_driver
in the gitattributes file, then in your gitconfig add something like:
[merge "my_merge_driver"]
name = descriptive name
driver = my_script %O %A %B
The three arguments for the script are the common ancestor version (O for original), the current branch's version (A) and the other branch's version (%B) - they're temporary files, and the merge driver is supposed to do the merge and leave the result in %A. See man gitattributes
for more about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With