Undo git update-index --assume-unchanged <file>
To synthesize the excellent original answers from @adardesign, @adswebwork and @AnkitVishwakarma, and comments from @Bdoserror, @Retsam, @seanf, and @torek, with additional documentation links and concise aliases...
Basic Commands
To reset a file that is assume-unchanged back to normal:
git update-index --no-assume-unchanged <file>
To list all files that are assume-unchanged:
git ls-files -v | grep '^[a-z]' | cut -c3-
To reset all assume-unchanged files back to normal:
git ls-files -v | grep '^[a-z]' | cut -c3- | xargs git update-index --no-assume-unchanged --
Note: This command which has been listed elsewhere does not appear to reset all assume-unchanged files any longer (I believe it used to and previously listed it as a solution):
git update-index --really-refresh
Shortcuts
To make these common tasks easy to execute in git, add/update the following alias section to .gitconfig
for your user (e.g. ~/.gitconfig
on a *nix or macOS system):
[alias]
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
unhide-all = ! git ls-files -v | grep '^[a-z]' | cut -c3- | xargs git unhide --
hidden = ! git ls-files -v | grep '^[a-z]' | cut -c3-
To get undo/show dir's/files that are set to assume-unchanged run this:
git update-index --no-assume-unchanged <file>
To get a list of dir's/files that are assume-unchanged
run this:
git ls-files -v|grep '^h'
If this is a command that you use often - you may want to consider having an alias for it as well. Add to your global .gitconfig
:
[alias]
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
How to set an alias (if you don't know already):
git config --configLocation alias.aliasName 'command --options'
Example:
git config --global alias.hide 'update-index --assume-unchanged'
git config... etc
After saving this to your .gitconfig
, you can run a cleaner command.
git hide myfile.ext
or
git unhide myfile.ext
This git documentation was very helpful.
As per the comments, this is also a helpful alias to find out what files are currently being hidden:
[alias]
hidden = ! git ls-files -v | grep '^h' | cut -c3-
git update-index function has several option you can find typing as below:
git update-index --help
Here you will find various option - how to handle with the function update-index.
[if you don't know the file name]
git update-index --really-refresh
[if you know the file name ]
git update-index --no-assume-unchanged <file>
will revert all the files those have been added in ignore list through.
git update-index --assume-unchanged <file>