Tuesday, October 14, 2008

Excluding config file from version control

Every application has some kind of configuration file to load settings. For instance, ASP.NET applications make use of web.config file to get the connection string for database operations. Similarly, desktop applications use INI file. While developing the application, each developer use configuration file as per their need. If the source is maintained in source control system, developers have to take extra care not to commit such configuration files. If somebody does it by mistake, everybody's file will be altered while updating from the source control. There is a simple way to avoid such situation. Don't put the configuration file under source control. Instead, put a template of the file, something like "app.config.tmpl". Then, after the initial checkout, have the users do a normal OS copy of the template to the proper filename, like "app.config" and have users customize the copy. The file is unversioned, so it will never be committed.