According to man gitignore:
DESCRIPTION
A gitignore
file specifies intentionally untracked files that git should ignore. Note
that all the gitignore
files really concern only files that are not already
tracked by git; in order to ignore uncommitted changes in already tracked files,
please refer to the git update-index --assume-unchanged documentation.
So it doesn't help if you've already added them. It's mostly for preventing the addition in the first place. That way, you can ignore .tmp
files and add a whole directory without worrying that you'll add the .tmp
files.
I believe you can remove them from the index with:
git rm --cached file_to_stop_tracking_but_dont_want_to_delete.txt
Update:
Also, the .gitignore
needs to be at the base directory or at least above where those directories are. Also, take the "*" out of the directories:
phpMyAdmin/
nbproject/
inc/mysql_config.php
!.gitignore
And be careful of phpMyAdmin/
vs /phpMyAdmin
vs phpMyAdmin
. Also from man gitignore:
If the pattern ends with a slash, it is removed for the purpose of the
following description, but it would only find a match with a directory.
In other words, foo/
will match a directory foo
and paths underneath
it, but will not match a regular file or a symbolic link foo
(this is
consistent with the way how pathspec works in general in git).
If the pattern does not contain a slash /
, git treats it as a shell
glob pattern and checks for a match against the pathname without leading directories.
Otherwise, git treats the pattern as a shell glob suitable for consumption
by fnmatch(3)
with the FNM_PATHNAME
flag: wildcards in the pattern
will not match a /
in the pathname. For example, Documentation/*.html
matches Documentation/git.html
but not Documentation/ppc/ppc.html
. A
leading slash matches the beginning of the pathname; for example, /*.c
matches cat-file.c
but not mozilla-sha1/sha1.c
.