(reference, available) Git ignore rules. gitignore rules do not take effect solution

 

Git ignore rules:

In git, if you want to ignore a file and prevent it from being submitted to the repository, you can use the method of modifying the .gitignore file in the root directory (if there is no such file, you need to manually create this file yourself). This file holds one matching rule per line such as:

# This is a comment - will be ignored by Git

*.sample # Ignore all files ending in
.sample !lib.sample # Except lib.sample
/TODO # Only ignore TODO files in the project root directory, not subdir/TODO
build/ # Ignore all files in the build/ directory
doc/*.txt # Ignore doc/notes.txt but not doc/server/arch.txt

  Solution for .gitignore rules not taking effect

Some directories or files are added to the ignore rule, and it is found that it does not take effect after being defined according to the above method. The reason is that .gitignore can only ignore those files that were not tracked before. If some files have been included in the version management, they will be modified. gitignore is invalid. Then the solution is to delete the local cache first (change it to an untracked state), and then submit it:

git rm -r --cached .
git add .
git commit -m 'update .gitignore'

 

 

Quote: http://www.cnblogs.com/zhangxiaoliu/p/6008038.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326081468&siteId=291194637