4

I was hoping you folks could recommend a "best practice" for source controlling binary assets for a Rails site in git.

My main concern is that as we work on the site, constantly adding and removing 500kb+ images from our git repo, the repo will eventually get pretty fat and unwieldy and we'll either have to manually remove those images from history (prone to disaster, as far as I can tell) or put up with a long initial download and extra wasted space on disk.

What are some alternatives for separating the app's logic from the assets? Git submodules? Anything else?

Thanks!

Alexandr Kurilin
  • 7,685
  • 6
  • 48
  • 76
  • Why are you constantly adding/removing those images? Through `rake assets:clean` and `rake assets:precompile` to rebuild your assets? – deefour Jun 15 '12 at 01:03
  • What I meant is that, when iterating over the site's UX, you often have to edit the assets and commit the updated version to source control. Since git, as far as I understand, is optimized for text compression, and not so much for binary formats, I'm trying to figure out a way to store these assets separately from the site logic (Rails, in my situation). – Alexandr Kurilin Jun 15 '12 at 01:09

2 Answers2

0

It seems this is pretty well covered elsewhere on SO and elsewhere. A start (after 5 seconds of searching):

If you're really seeing bloat in your repo and are wanting to keep the main rails app repo free of this, you can look into git submodules - all changes to the images would be kept within a separate assets (for example) repo, keeping your main repo free of incurred bloat.

Community
  • 1
  • 1
deefour
  • 34,974
  • 7
  • 97
  • 90
  • So this is a close-as-duplicate and a reiteration of the submodule idea in the OP? – Dave Newton Jun 15 '12 at 04:09
  • Unless I'm missing something, sure. Googling "how does git handle binary files", "git binary file diff", "git binary file bloat" etc.. comes up with plenty of relevant, already popular SO questions/answers. – deefour Jun 15 '12 at 04:20
-1

Add the images folder to your .gitignore file. e.g.

/app/assets/images/*
iHiD
  • 2,450
  • 20
  • 32
BK22
  • 85
  • 3