Git ignores and the. gitignore rule does not take effect. git. gitignore
Git ignore rules:
If you want to ignore a file in git and prevent it from being submitted to the version library, you can modify it in the root directory. gitignore file method (if this file is not available, you need to manually create this file ). Each row of this file stores a matching rule, for example:
# This is a comment-it will be ignored by Git
*. Sample # ignore all files ending with. sample
! Lib. sample # Except lib. sample
/TODO # ignore the TODO file in the root directory of the project, excluding subdir/TODO
Build/# ignore all files in the build/directory
Doc/*. txt # will ignore doc/notes.txt, but does not include doc/server/arch.txt
. Gitignore rule does not take effect
Some directories or files are added to the ignore rule. After being defined according to the above method, it is found that the rule does not take effect because. gitignore can only ignore untracked files. If some files have been included in version management, modify them. gitignore is invalid. The solution is to first Delete the local cache (change to the untracked status), and then submit:
Git rm-r -- cached.
Git add.
Git commit-m'update. gitignore'