Git ignores the rules and the. Gitignore rule does not take effect for the workaroundshare to: more
2015-02-12 Category: Share2 people reviews 65,215 times people viewed
In Git, if you want to ignore a file and not commit the file to the repository, you can use the method that modifies the. gitignore file in the root directory (if none, you need to manually build the file yourself). Each row of this file holds a matching rule for example:
| 1234567 |
# this as comment – will be ignored by Git *.a # ignores all. A end-of-file !lib.a # except LIB.A /todo # simply ignores the TODO file under the project root and does not include Subdir/todo build/ # Ignore All files in build/directory doc/*.txt # ignores doc/notes.txt but does not include Doc/server/arch.txt |
The rules are simple, do not explain too much, but sometimes in the project development process, suddenly a sudden whim want to add some directories or files to ignore the rules, according to the above method definition found not effective, The reason is that. gitignore can only ignore files that were not previously track, and if some files have already been included in version management, modify the. Gitignore is not valid. The workaround is to first delete the local cache (to change to a non-track state) before committing:
| 123 |
git rm-r --cached .git add .git commit -m ‘update .gitignore‘ |
. Gitignore Non-valiate