Git extended ignore
Mine .gitignore
looks something like this:
# Ignore everything
*
# But not these files...
!.gitignore
!ImportantDirectory/
!AnotherImportantDirectory
# Actually, ignore these...
ImportantDirectory/NotImportantFile
The problem is it ImportantDirectory/NotImportantFile
is still being tracked. Any idea how to solve this?
source to share
If you previously included this file, it will continue to be tracked until you remove it from your repository, even if you list it in .gitignore. It looks like this is what's going on here. You can do it with
git rm --cached ImportantDirectory/NotImportantFile
Note. This will remove the file from the .git repository, but it will not remove the local file on disk. Note, however, this will remove ImportantDirectory/NotImportantFile
for anyone pulling your git repository, so if it's a file that also needs to be maintained but not included, you may need a different approach.
source to share