Global git ignore content for
~/.gitignore- a user-wide git ignore file applied to all repos
See my full .gitignore file.
First, configure your git config to be aware of a
~/gitignore file. You can name it anything you want.
[core] excludesfile = "~/.gitignore"
Here's a quick to set that. Note that this won't add the double quotes but it will still expand correctly.
$ git config --global core.excludesfile '~/.gitignore'
Now setup the actual file. This follows the same format as a repo-specific file but it is not tied to a repo.
$ touch ~/.gitignore
Then open it in your IDE. Use
touch above to open in VS Code.
The rest of this post covers the content you can add to that file.
Sometimes files you don't want to version get left off of a repo's ignore file. For example it is only created using a certain OS or IDE and so it doesn't cross your mind to ignore it.
Here's a way to ignore files without having to add them to all your repos and this is especially useful if you are working on someone else's repo and you use a different OS or IDE to them.
# Linux folder attributes (Dolphin) and PyCharm metadata. .idea/ .directory/ # macOS folder attributes. .DS_Store # Vim swap file. .swp
The vim temporary file is a rare case - it is created when editing a file including when using vimdiff. It is easiest just to ignore it globally.
The content of my global git ignore file means I can have these in a repo without having to ignore them in a project ignore file.
TODO _TODO NOTES _NOTES # Avoid just 'TEST' as sometimes 'test' is a valid directory in some projects. _TEST _TESTS
For example, I can text files in a directory (I don't both with
Or add a directory of notes or work-in-progress.