How to ignore files in Git after being modified
This is useful when the .gitignore
doesn't work as expected.
To ignore the change use:
$ git update-index --assume-unchanged /path/to/file
To revert the ignore attribute:
$ git update-index --no-assume-unchanged /path/to/file
So, this alias could be useful for your .gitconfig
:
[alias]
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
Or adding the alias using:
$ git config --global alias.hide 'update-index --assume-unchanged'
$ git config --global alias.unhide 'update-index --no-assume-unchanged'
And use it:
$ git hide myfile.ext
$ git unhide myfile.ext