git – ignore vim temporary files in all directories

24 Jul 2009

Up until a few weeks ago I was using subversion for all my personal stuff.

But then I got fredded when my free subversion hosting ( went down for a few days, so I’ve moved to git. Yay, no more central repository to go down.

To ignore files in git you use .gitignore, eg for a rails project:

% cat .gitignore

But how to ignore files in all directories? Use .git/info/exclude. For example, to ignore all temporary files generated by vim:

% cat .git/info/exclude

All the howto’s I’ve read so far mention .gitignore but not .git/info/exclude – I stumbled across this by accident. More RTFM’ing to do.


To ignore all files in all directories, .gitignore can be used. A bit of experimentation and reading of man gitignore shows that any wildcard that doesn’t contain a / will apply to that directory and all child directories.

.gitignore is propagated during clone operations, whereas .git/info/exclude isn’t ie use the former for common settings and the latter for personal settings.

From the manpage:

Patterns which should be version-controlled and distributed to other repositories via clone (i.e., files that all developers will want to ignore) should go into a .gitignore file. 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/exclude file. Patterns which a user wants git to ignore in all situations (e.g., backup or temporary files generated by the user´s editor of choice) generally go into a file specified by core.excludesfile in the user´s ~/.gitconfig.

comments powered by Disqus

  « Previous: Next: »