reggie
reggie

Reputation: 3674

Git ignore mongod.log

I tried several different combinations, but I was not able to exclude the mongodb log from git.

My gitignore:

mongodb/data/
mongodb/data/log/mongod.log
mongodb/data/**/*.log
/mongodb/data/**/*.log

None of them work. When I type

git status

I still get the following:

modified: mongodb/data/log/mongod.log

How can I ignore this file? The data under mongodb/data/db is ignored. I do not understand why the log file is constantly showing up again.

Upvotes: 0

Views: 967

Answers (1)

javierfdezg
javierfdezg

Reputation: 2107

Once you have a file in the git tree, it's not enough to add it to the .gitignore file, as it still belongs to the tree and git will take care of.

The .gitignore file is intended to be used before you add files to the tree.

In your situation you have to remove the file from the tree with:

git rm path/to/file

You also will have to commit the deletion.

If you want to keep a copy where it is at the moment, move it to /tmp, issue a git status (it should be marked as deleted), make a commit and move it again to the original place.

I'd suggest to use the global git configuration for widely used common files that are likely to be ignored in other projects. You can check out this question: Global Git ignore

Upvotes: 6

Related Questions