Ignoring Files on Git (but Just for a While)

Sometimes, you might want to make changes to files that are tracked without having the need to commit them.

· Agile Zone · Opinion
Save
6.32K Views

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.

Published at DZone with permission of Simone Chiaretta, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Comments
X