Goal
Mark generated (concatenated and minified) JavaScript files and CSS files as binary files within Git to allow checking them in while avoiding merge conflicts (currently, I don’t check these files in).
Failure
I have been unable to get this to work so I thought I’d document my issue here and update this page when I have a resolution. I’m hoping someone more knowledgable than I on the topic of Git can help me understand where I’m failing.
Update 2016-08-26 I have given up on this quest and currently check in my generated JavaScript and CSS on any projects where I use Git for deployment.
My environment
- MacBook Pro running 10.9.2 (Mavericks)
- Git version 1.8.4
- Using repo https://github.com/salcode/git-force-binary-test
Test if a File is Binary
Currently, I’m using the following technique to test if a file is treated as binary by Git.
git merge-file /dev/null /dev/null file-to-test
from Stack Overflow How to determine if Git handles a file as binary or as text?.
Specifically, I’m using the lines
git merge-file /dev/null /dev/null 200x200.gif
Result error: Cannot merge binary files: 200×200.gif
and
git merge-file /dev/null /dev/null style.min.css
Result (no message, indicates NOT a binary file)
Change I’m Making
I’ve added a .gitattributes file to the repo, which includes the line style.min.css binary
.
My understanding is this line should force Git to treat style.min.css as a binary file.
As per http://git-scm.com/book/en/Customizing-Git-Git-Attributes#Binary-Files
Expected Result
git merge-file /dev/null /dev/null style.min.css
Result error: Cannot merge binary files: style.min.css
Actual Result
git merge-file /dev/null /dev/null style.min.css
Result (no message, indicates NOT a binary file)
Leave a Reply