-
Notifications
You must be signed in to change notification settings - Fork 0
Hide Files
Eric Bouchut edited this page Feb 19, 2020
·
2 revisions
You may sometimes need to ignore a file already tracked by git.
Using the files .gitignore
or .git/info/exclude
won't work in this case but the following command may come in handy.
Run the following command to temporarily exclude a file from git tracking, pretending it never changed.
We hide this file from git.
git update-index --assume-unchanged FILE
Later on, if you need to commit changes to this file, simply use the opposite command to unhide this file from git:
git update-index --no-assume-unchanged FILE
If you want to unhide all hidden files:
git update-index --really-refresh
To list the files hidden from git, use this:
git ls-files -v | grep '^[a-z]' | cut -c3-
The below aliases may come in handy if you intend to use the above commands on a regular basis or need an easier way to remember them without the syntax burden.
git config --global alias.hide 'update-index --assume-unchanged`
git config --global alias.unhide 'update-index --no-assume-unchanged`
git config --global alias.unhide-all 'update-index --really-refresh'
git config --global alias.hidden '!git ls-files -v | grep '^[a-z]' | cut -c3-'