Search code examples
gitsvn

Is there a Git equivalent to SVN's ignore-on-commit?


In SVN, it is possible to add versioned files to a special change list called ignore-on-commit.

The effect is that the files will not be included in commits by default, unless they are explicitly selected (e.g. in a graphical client where files to commit have to be selected with checkmarks) even when they are changed.

I have already found that the general "change list" feature does not exist the same way in Git, but here, I am rather looking for something more specific. I am not asking for general change lists, but for a way to mark certain versioned files as exempt from commits by default, possibly even to the extent that when switching/merging, those files are automatically reverted.


Solution

  • What you're asking is, in general, a question about how to ignore changes to tracked files, which the Git FAQ is clear that Git doesn't support. The FAQ is also clear that some people try to suggest approaches which don't work and you shouldn't use:

    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.

    If your goal is to work with things like configuration files, the FAQ proposes a solution:

    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.