Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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:

[core]
    excludesfile = /home/soleary/.gitignore

And in .gitignore I have:

.*.swp

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
1  
You may want to add .gitignore to your repo for other users. –  tjameson Apr 4 '11 at 16:37

.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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.