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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
.gitattributesfile, add something like: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_driverin the gitattributes file, then in your gitconfig add something like: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 gitattributesfor more about this.