One of the most common issues we all face when versioning code on source repositories involves being able to make changes to files that are tracked without committing them. A typical example is the
web.config file in Umbraco projects. The version in source control should be the default "uninstalled" version, while each developer will have their own with local configurations.
Probably some of these scenarios could be solved with other approaches, like writing
.user config files, but a solution that solves all of these issues is using the
update-index command of Git.
You can type
git update-index --assume-unchanged <file> to temporarily exclude the file from any tracking, pretending it never changed. When you actually need to commit an actual change to the file, you can use the opposite command,
git update-index --no-assume-unchanged <file>.
The only problem is that I cannot find a way to list which files are untracked. However, it nicely solves the problem of making configuration changes that we don't want to commit in a way that is transparent for the solution being developed.
Have you ever used this approach before? What do you think? Let me know in the comments.