I\'m trying to make git ignore some of my files and I found one description about how you could do this
From: http://github.com/guides/git-cheat-sheet T
https://www.gitignore.io/
I created a web utility that can help you generate useful .gitignore files for your project. It will help you ignore operating system, programming language, and IDE generated files.
According to man gitignore:
DESCRIPTION
A
gitignore
file specifies intentionally untracked files that git should ignore. Note that all thegitignore
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 directoryfoo
and paths underneath it, but will not match a regular file or a symbolic linkfoo
(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
matchesDocumentation/git.html
but notDocumentation/ppc/ppc.html
. A leading slash matches the beginning of the pathname; for example,/*.c
matchescat-file.c
but notmozilla-sha1/sha1.c
.