gitignore not working - being ignored?
Asked Answered
G

1

-1

i've got this problem: got a file under $MYAPP/application/config/database.php that contains all the informations about how to connect to the mysql dbms. Now, these data are different between my local environment and the production environment.

So i've made a .gitignore (under the root of my git project - $MYAPP) that indicates to ignore application/config/database.php file from commits.

Now, on the remote production environment, I modify this file. How is possible that when i make ANY modification to ANY (and not database.php) file, ask for a git status (where database.php is not mentioned), push and on the remote environment I find the same copy of my local environment database.php version? It seems that git is "ignoring my .gitignore file"

Thanks for help Regards.

Galata answered 20/10, 2015 at 22:30 Comment(3)
Can you show us the .gitignore entry? Is database.php already added? Are you committing changes to it? (You can check with git log --stat) How is your remote environment being updated? (Normally this is not done by git)Empressement
This is a common problem. It's due to the fact that .gitignore doesn't mean "ignore" at all. It has instead two different meanings: "shut up about untracked file" (in git status output) and "don't auto-add that file when adding 'all' files" (in git add . for instance). If the path is already in the index, though, neither of these do anything. See https://mcmap.net/q/11358/-git-ignore-vs-exclude-vs-assume-unchanged for caveats about the standard --assume-unchanged workaround.Diakinesis
Possible duplicate of Stop tracking and ignore changes to a file in GitChapel
E
1

There's two things I can guess are going on. First, .gitignore only ignores untracked files. If application/config/database.php has previously been added, and you're pounding on git commit -a, then changes to it will be committed.

To check, run git log --stat and see if changes to application/config/database.php show up. If so, then the file is already added and you've been committing changes. To remove it from Git, but not delete the file, use git rm --cached application/config/database.php.

If this is the case, pay attention to what you're committing.


The other possibility is that this has nothing to do with Git. You don't say how your remote environment is being updated. If you have an install script, it could be something that is doing.

Empressement answered 20/10, 2015 at 22:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.