index.html commit hell

3One of the issues we face when dealing with angular apps is the number of js files that need to be included in the index.html. Especially when you are working on a large project, the number of js files can reach over 100. In order to combat that, and make things easier for developer, tools like wiredep and gulp-inject were created. These tools search the directory structure, and add the js and css files to the index.html.

There is a problem however that these tools cause when in teams. If there are two people working on the project, and each of them creates js files for their tasks, when they try to merge they will get merge conflict even though they aren’t even working on the same files. This is due to the fact that the changes to the index.html are automatic. The conflicts themselves don’t matter, as the file will be rebuilt anyway, but it can be very confusing.

The way I solved this problem is by removing the index.html entirely from the repository. The way you do this is by making a copy of your index.html to index.template.html and deleting index.html. Next you add index.html to your vcs’s version of a .gitignore. Finally you modify your gulp/grunt tasks to copy over a new index.html each time you build.

The problem this solves is one that we dealt with on a daily basis. You may think that getting merge conflicts on just one file isn’t much, but when you are merging ten or more a day for a file that quite literally doesn’t matter, it starts to wear on you. It takes about ten minutes to make this change, and it saves about 2-3 minutes every time you would have needed to merge the file. Over a month, the time savings could be quite large.

One comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s