The drawback of using git update-index --assume-unchanged
is that (as the git manual states), you're promising git that you're not going to change the file.
When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index.
If you violate this promise and change the file anyway it can have undesirable consequences. E.g. on some implementations, doing a git stash
will throw away the changes you made to the file (why shouldn't it if you promised you weren't going to change it?).
Using the --skip-worktree option instead tells git to pretend the working version is up to date with the index version.
When reading an entry, if it is marked as skip-worktree, then Git pretends its working directory version is up to date and read the index version instead.
This seems to be the more reliable way to ignore changes without the risk that some git commands might throw your changes away:
git update-index --skip-worktree path/to/file
To track the file again:
git update-index --no-skip-worktree path/to/file
To list the files where you've set the skip-worktree
:
git ls-files -v | grep ^S