If you are trying to ignore a file and git is mucking you about, it may be because the file you are trying to ignore is already in the repository, and therefore it sees it as a change, and will probably delete the file.
Instead, run this command line function:
git update-index --assume-unchanged
i.e.
git update-index --assume-unchanged application/config/database.php
Run this for all the files you need to ignore after the initial checkout.