Sometimes we need to hide some files already added before to a repository from accidental commit to Git. I will show you, how you can do this.
Git has a great flag named assume-unchanged. For example, you have a config file, which you changed and you don’t want to commit it.
You can use below command to protect given file:
git update-index --assume-unchanged config_file.yml
After this command git will not show this file anymore in changed files.
If you want to git find changes in the file, you can reset the flag:
git update-index --no-assume-unchanged config_file.yml
List of hidden files
Sometimes you want to check, which files are hidden. You can list them using the command:
git ls-files -v | grep '^h'
Alias for a list of hidden files
For simplicity, you can add an alias for above command. To do this, you can add below alias to your .gitconfig file in the home directory:
[alias] hidden = !git ls-files -v | grep "^h"
Now, you can use
git hidden command to list hidden files.