Take the 2-minute tour ×

I want to git ignore cache directories in my project. I read on the internet that I'm supposed to use the gitignore command. But when I did, bash complains about command does not exist. I tried running an apt-get install gitignore, but package does not exist.

How do I tell git to ignore my cache directory?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

You don't need to install anything else, you just need to set up Git to ignore the things you don't want. .gitignore is the file name, there is no command to interface with these files.

I have this is my ~/.gitconfig file:

    excludesfile = /home/soleary/.gitignore

And in .gitignore I have:


This gives me a global file that ignores swap files in all of my git projects. If you want to do it on a per repo basis, you can create a .gitignore file in the top-level directory for that project. (The same level as that repo's .git directory.)

See man gitignore for more info.

share|improve this answer
You may want to add .gitignore to your repo for other users. –  tjameson Apr 4 '11 at 16:37
add comment

.gitignore is a file that contains the stuffs you don't want to put in your repository. In your parent directory:

echo "cache" > .gitignore

will ignore the directory "cache"

share|improve this answer
+1 Same as Sean O'Leary's answer, but you directly answered his question. I would also suggest adding this to your repo for everyone else. –  tjameson Apr 4 '11 at 16:39
add comment

Your Answer


