Is there a Git equivalent to Plastic's hidden_changes.conf?

38 Views Asked by At

Plastic defines the hidden_changes.conf file as such:

Hiding changes with hidden_changes.conf

Just like you sometimes need to ignore private files with ignore.conf, there are scenarios where you don’t want Plastic to detect changes in specific files because you don’t want to accidentally include them in the next checkin. This can happen if you need to adjust config files for a debug session or alter some source code for whatever reason, but you don’t want to checkin those temporary changes.

hidden_changes.conf helps achieve that.

generally we used this file in Plastic to supply a list of files that always needed to be present (mostly "defaulted" settings and configurations), which were expected to be changed per developer (as needed), but should never be checked back into source control.

Does Git provide a similar file/feature? I am only aware of the .gitignore file and that obviously does not serve the same purpose.

1

There are 1 best solutions below

2
bk2204 On

No, Git doesn't support ignoring changes to tracked files. The Git FAQ says this:

Git doesn’t provide a way to do this. The reason is that if Git needs to overwrite this file, such as during a checkout, it doesn’t know whether the changes to the file are precious and should be kept, or whether they are irrelevant and can safely be destroyed. Therefore, it has to take the safe route and always preserve them.

It’s tempting to try to use certain features of git update-index, namely the assume-unchanged and skip-worktree bits, but these don’t work properly for this purpose and shouldn’t be used this way.

However, the FAQ mentions the recommended approach for config files and similar types of situations:

If your goal is to modify a configuration file, it can often be helpful to have a file checked into the repository which is a template or set of defaults which can then be copied alongside and modified as appropriate. This second, modified file is usually ignored to prevent accidentally committing it.