2

I have a repo that contains my minified css/js files. Some of them are gzipped. When i go between staging and production doing push and pulls it tries to auto merge and fails on the gz ones citing it cannot auto merge binary files.

Is there a way to tell git to never try to merge a certain directory but rather only push that directories changes when a push request is made?

Any other ways you guys go about this?

Thanks!!

UPDATE:

I tried putting the following in .gitattributes

*.gz merge=keepTheir

And still getting this whenever I push: (mind you, someone else pushed before me and updated files into that repo)

Auto-merging public/assets/upload.css.gz
CONFLICT (content): Merge conflict in public/assets/upload.css.gz

What am I doing wrong?

4
  • Did you define the keepTheir script, as described in stackoverflow.com/questions/4911794/…? The .gitattributes is just there to declare what script need to be executed on merge. See also stackoverflow.com/questions/928646/… for a more detailed example.
    – VonC
    Commented Mar 26, 2011 at 19:49
  • Note: other "copymerge" strategies exist: stackoverflow.com/questions/4911794/…
    – VonC
    Commented Mar 26, 2011 at 19:51
  • dumb me, i did not. But now that I understand that my next question is, what paths are being produced by git $3 and $2?.... And also what if I wanted to make a keepOurs strategy script? Would I do mv -f $2 $3? Would keep ours make sure that it uploads to the repo my latest changes and keep my local copies intact the way they are?
    – schone
    Commented Mar 26, 2011 at 19:56
  • if you want to keep your local copy intact, a keepOursis better ;) That is what stackoverflow.com/questions/928646/… describes
    – VonC
    Commented Mar 26, 2011 at 20:07

2 Answers 2

3

If you need the content you want to push to overwrite (instead of merge) the destination, you can define a custom merge driver in .gitattribute file in order to specify how you want the *.gz files to be merged.

See this answer as an example.

.gitattributes

*.gz merge=keepTheir

(based on "git command for making one branch like another")

1
  • update question w/ examples. Still running into problems. I'd appreciate any guidance you can give me please.
    – schone
    Commented Mar 26, 2011 at 19:44
1

Maybe you want to ignore the minified version because they are just a minified representation of the full files?

Include the filenames in /.gitignore and commit a change adding this file. Git will stop tracking changes to the minified de-facto-copies uselessly.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.