Can I ignore files locally without polluting the global git config for everyone else? I have untracked files that are spam in my git status but I don't want to commit git config changes for every single little random untracked file I have in my local branches.
Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the
$GIT_DIR/info/excludefile.
The .git/info/exclude file has the same format as any .gitignore file.
You can also set core.excludesfile to the name of a file containing global patterns.
Note on $GIT_DIR: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.
You have several options:
- Leave a dirty (or uncommitted)
.gitignorefile in your working dir (or apply it automatically using topgit or some other such patch tool). - Put the excludes in your
$GIT_DIR/info/excludefile, if this is specific to one tree. - Run
git config --global core.excludesfile ~/.gitignoreand add patterns to your~/.gitignore. This option applies if you want to ignore certain patterns across all trees. I use this for.pycand.pyofiles, for example.
Also, make sure you are using patterns and not explicitly enumerating files, when applicable.