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?

schone
  • 562
  • 4
  • 13
  • Did you define the `keepTheir` script, as described in http://stackoverflow.com/questions/4911794/git-command-for-making-one-branch-like-another/4912267#4912267? The `.gitattributes` is just there to declare what script need to be executed on merge. See also http://stackoverflow.com/questions/928646/how-do-i-tell-git-to-always-select-my-local-version-for-conflicted-merges-on-a-sp/930495#930495 for a more detailed example. – VonC Mar 26 '11 at 19:49
  • Note: other "copymerge" strategies exist: http://stackoverflow.com/questions/4911794/git-command-for-making-one-branch-like-another/4912267#4912267 – VonC Mar 26 '11 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 Mar 26 '11 at 19:56
  • if you want to keep your local copy intact, a `keepOurs`is better ;) That is what http://stackoverflow.com/questions/928646/how-do-i-tell-git-to-always-select-my-local-version-for-conflicted-merges-on-a-sp/930495#930495 describes – VonC Mar 26 '11 at 20:07

2 Answers2

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")

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • update question w/ examples. Still running into problems. I'd appreciate any guidance you can give me please. – schone Mar 26 '11 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.

Daniel Böhmer
  • 14,463
  • 5
  • 36
  • 46