1

I'll try to explain with a scenario: a website. Assume that you need a particular graphical element so you choose to create a PSD file for it and you put it under version control. But for maintaining the coherence between commits you should also submit the generated PNG file.

Is this the proper approach to the problem?

Bonus: Can you provide a good online reference that talks about that kind of practices?

I add the Git tag because I'm mainly interested to this particular software, but I guess it's a common issue.

cYrus
  • 2,976
  • 6
  • 29
  • 47
  • possible duplicate of [Should I store generated code in source control](http://stackoverflow.com/questions/893913/should-i-store-generated-code-in-source-control) – CharlesB Nov 04 '11 at 10:56

2 Answers2

2

Yes, there are sometimes good reasons to keep both the generating file and the generated file under version control. But perhaps your scenario is not one of them, if you assume that all the developers working on the project have access to the generator (apparently some Adobe software is used to transform *.psd files to *.png files, so this supposes that all the developers have access to that Adobe software, and that they can run it from the building procedure). You could also keep image files e.g. as SVG files (edited by inkscape).

Good reasons to keep both generating and generated variants include bootstrapped systems. When you develop a language in itself, translated by its own translator, you'll need to keep both variants under version control. I know at least of two examples: Ocaml, whose bytecode & native compilers are written in Ocaml, so the (generated) bytecode form of the compiler is kept under SVN, and my GCC MELT, a high level domain specific language for GCC. The MELT translator (from MELT DSL to C) is coded in MELT, so I keep the translated form (as generated C code) under version control, together with the MELT source code form of it.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • 1
    Yes, in theory you're right, it's always possible to recreate PNGs from the PSD, but it might be quite slow and it will slow down the whole Git workflow, switching branches for example. Does this legitimate to put PNGs under version control? This differs from source code -> executable IMO since HTML is somewhat both source and output and HTML uses PNGs. – cYrus Nov 04 '11 at 11:19
  • But keeping both generating & generated files under VC opens the door to naughty errors like too old generated files under VC, etc. I don't think that generating time should be a concern. And people don't switch branches very often... (and they could keep several branches on different file trees on their development machines) – Basile Starynkevitch Nov 04 '11 at 11:28
  • What you mean with: _and they could keep several branches on different file trees on their development machines_? How can this helps this situation? – cYrus Nov 04 '11 at 11:33
  • 1
    Developer Joe could, when he have to work on branchA & on branchB, checkout them under `$HOME/branchA` and `$HOME/branchB` because disk space on developper's machine is cheap. He generates the *.png on both file trees, so he don't lose time when going from branchA to branchB. – Basile Starynkevitch Nov 04 '11 at 11:43
0

I'd say that if you can build the whole site from source in a single script, then you shouldn't source-control generated files. This is preferred (but not easy to do sometimes), because this way history is reduced to bare essentials, the source.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • See [my comment](http://stackoverflow.com/questions/8008124/version-controlling-both-source-and-output-file/8008210#8008210). – cYrus Nov 04 '11 at 11:20