Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to put under version control?

Almost any IDE creates lots of files that have nothing to do with the application being developed, they are generated and mantained by the IDE so he knows how to build the application, where the version control repository is and so on.

Should those files be kept under version control along with the files that really have something to do with the aplication (source code, application's configuration files, ...)?

The things is: on some IDEs if you create a new project and then import it into the version-control repository using the version-control client/commands embedded in the IDE, then all those files are sent to the respitory. And I'm not sure that's right: what is two different developers working on the same project want to use two different IDEs?


I want to keep this question agnostic avoiding references to any particular IDE, programming language or version control system. So this question is not exactly the same as these:

  • SVN and binaries - but this talks about binaries and SVN
  • Do you keep your build tools in version control? - but this talks about build tools (e.g. putting the jdk under version control)
  • What project files shouldn’t be checked into SVN - but this talks about SVN and dll's
  • Do you keep your project files under version control? - very similar (haven't found it before), thanks VonC
like image 226
mmutilva Avatar asked Dec 10 '09 12:12

mmutilva


People also ask

What is an example of version control?

Version control is a component of software configuration management. Changes are usually identified by a number or letter code, termed the "revision number", "revision level", or simply "revision". For example, an initial set of files is "revision 1".


2 Answers

Rules of thumb:

  1. Include everything which has an influence on the build result (compiler options, file encodings, ASCII/binary settings, etc.)
  2. Include everything to make it possible to open the project from a clean checkout and being able to compile/run/test/debug/deploy it without any further manual intervention
  3. Don't include files which contain absolute paths
  4. Avoid including personal preferences (tab size, colors, window positions)

Follow the rules in this order.

[Update] There is always the question what should happen with generated code. As a rule of thumb, I always put those under version control. As always, take this rule with a grain of salt.

My reasons:

Versioning generated code seems like a waste of time. It's generated right? I can get it back at a push of a button!

Really?

If you had to bite the bullet and generate the exact same version of some previous release without fail, how much effort would it be? When generating code, you not only have to get all the input files right, you also have to turn back time for the code generator itself. Can you do that? Always? As easy as it would be to check out a certain version of the generated code if you had put it under version control?

And even if you could, could you ever be sure that didn't miss something?

So on one hand, putting generated code under version control make sense since it makes it dead easy to do what VCS are meant for: Go back in time.

Also it makes it easy to see the differences. Code generators are buggy, too. If I fix a bug and have 150'000 files generated, it helps a lot when I can compare them to the previous version to see that a) the bug is gone and b) nothing else changed unexpectedly. It's the unexpected part which you should worry about. If you don't, let me know and I'll make sure you never work for my company ever :-)

The major pain point of code generators is stability. It doesn't do when your code generator just spits out a random mess of bytes every time you run (well, unless you don't care about quality). Code generators need to be stable and deterministic. You run them twice with the same input and the output must be identical down to least significant bit.

So if you can't check in generated code because every run of the generator creates differences that aren't there, then your code generator has a bug. Fix it. Sort the code when you have to. Use hash maps that preserve order. Do everything necessary to make the output non-random. Just like you do everywhere else in your code.

Generated code that I might not put under version control would be documentation. Documentation is somewhat of a soft target. It doesn't matter as much when I regenerate the wrong version of the docs (say, it has a few typos more or less). But for releases, I might do that anyway so I can see the differences between releases. Might be useful, for example, to make sure the release notes are complete.

I also don't check in JAR files. As I do have full control over the whole build and full confidence that I can get back any version of the sources in a minute plus I know that I have everything necessary to build it without any further manual intervention, why would I need the executables for? Again, it might make sense to put them into a special release repo but then, better keep a copy of the last three years on your company's web server to download. Think: Comparing binaries is hard and doesn't tell you much.

like image 71
Aaron Digulla Avatar answered Oct 05 '22 13:10

Aaron Digulla


I think it's best to put anything under version control that helps developers to get started quickly, ignoring anything that may be auto-generated by an IDE or build tools (e.g. Maven's eclipse plugin generates .project and .classpath - no need to check these in). Especially avoid files that change often, that contain nothing but user preferences, or that conflict between IDEs (e.g. another IDE that uses .project just like eclipse does).

For eclipse users, I find it especially handy to add code style (.settings/org.eclipse.jdt.core.prefs - auto formatting on save turned on) to get consistently formatted code.

like image 29
sfussenegger Avatar answered Oct 05 '22 13:10

sfussenegger