Reputation: 1036
I need to exclude dbconfig.php from git repository. How can I remove it from the current indexing in the current repository? Can I exclude it from being added to the repo even when running git add .
Thanks!
Upvotes: 0
Views: 346
Reputation: 13733
First, remove the file from the index:
git rm --cached dbconfig.php
Then, in the root of the repository, create .gitignore
and add dbconfig.php
to it.
git add .gitignore
and git commit -m "new gitignore"
and it should go missing the next time you do a git status
or add .
Upvotes: 4
Reputation: 526503
Add a file named .gitignore
in the repository and put a line in it:
dbconfig.php
Then git add .gitignore
and commit it.
If you already committed the file before, you might want to reset to back before you committed it and re-add the other files, omitting the one you don't want tracked. (Removing it and committing again would remove it from tracking, but the history would still be there - assuming the file contains sensitive data, you wouldn't want that.)
http://help.github.com/ignore-files/
Upvotes: 1