If you use a IDE with some cache files, have some MacOS cache files, or always use a tmp directory which you want to auto ignore, this post can help
Ignoring local folders without having to update .gitignore
It sometimes happens where you create a local file or folder for a project, but do not want to commit it, and neither make a change to
Being able to ignore these changes, will allow you to still use
git add . without having to exclude any of your local folders.
Git has a built-in
--assume-unchanged flag on
update-index you can use to tell git to not consider the current changes.
To ignore the tmp file, without editing
.gitignore , use
git update-index --assume-unchanged <file-list>
$ git update-index --assume-unchanged <file>
If you need to undo this operation, you can use
$ git update-index --no-assume-unchanged <file>
Ignoring files globally
Git can have a global ignore file, for ignoring certain patterns across your entire machine.
First, tell git where to find the global Git Ignore file. For this post, we'll assume
core.excludesFile which points at the ignore file
$ git config --global core.excludesFile '~/.gitglobalignore'
Then you can add any excludes in there which are specific to your machine.
NOTE: Be careful of ignoring common programming files such as
.pycache, as this might cause confusion and frustration for your colleagues. Ignore only files specific to your machine, such as IDE files, or temp files you commonly create.
My your code bring you joy.