1

I have a series of school projects that I manage using git. The folder structure is as follows, minus fluff:

MainDir/Lab [#]/Lab [#].cache/

Where [#] represents each lab number. I want to ignore the /Lab [#].cache/ directories. The .gitignore file is in MainDir, and I want to know the syntax for ignoring all the cache files.

Things I have tried:

**/*.cache    
**/*.cache/
**/Lab ?.cache/
*.cache
*cache/

I feel like I'm on the wrong track here. I've looked at the official documentation, as well as other questions like .gitignore: How do I ignore nested directories?, which looked like it should solve the problem, but it didn't.

Any help would be appreciated.

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112

1 Answers1

0

You should be able to ignore any Lab [#].cache/ folder with:

*.cache/

Note the final '/', important to ignore a folder.

However, make sure that folder content is not already tracked:

git rm -r --cache MainDir/Lab 1/Lab 1.cache/

Then make sure the .gitignore rule works:

git check-ignore -v -- MainDir/Lab 1/Lab 1.cache/aFile
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250