简体   繁体   中英

git ignore doesn't ignore already submitted files?

This is my .gitignore file:

src/main/resources/*
!src/main/resources/input

In the past i submitted a few files under resources folder.

Now I see some files are still monitored by git (as changed) even if they are under src/main/resources/foo1

how come the git ignore don't hide these files from the git status ?

gitignore governs only addition of new files, files that are already tracked continue to be tracked.

To remove them from Git but keep them in filesystem, use --cached option of rm :

git rm -r --cached src/main/resources

git (and other vcs) ignore only new files. If you already added file which should not be in a repository it is better to delete it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM