Question

In a project we are working on we have a bunch of boilerplate code that gets copied to a number of projects. We are using GIT for version control.

Currently I am using a .bat file to copy boilerplate files, set the read-only attribute on each file and apply a comment header to .js, .html and .css files waring the user that this file was generated automatically and not bother editing it.

This is working ok but not foolproof. If the boilerplate code is refactored and items deleted client projects will still have the old file hanging around. Git does not remember windows attributes such as read-only.

Is there a better way of doing this to overcome these restrictions?

Was it helpful?

Solution

I'd recommend using a Git subdmodule for this. You can have a clone/checkout hook that will run your script to add file headers. It won't solve the read-only problem, but that can be circumvented anyway. You can then distribute any updates to your boilerplate by doing git submodule update.

The caveat with this method is that your boilerplate must reside in a single folder. You could copy it out with your script but this will cause more problems than it solves.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top