2

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?

5

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.

  • 1
    You may want to add .gitignore to your repo for other users. – beatgammit Apr 4 '11 at 16:37
6

.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"

  • +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. – beatgammit Apr 4 '11 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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