Notes

Git ignore ALL caches

Edit on GitHub

Git & Github

Needed to do this for a WordPress site for which the source has been committed. The issue with WordPress is that there are too many caches! The plugins will add their own, the theme will add their own and so on..

Find all folders with cache in their name to get an idea of what you’re ignoring..

1find . -type d -name *cache
./wp-content/et-cache
./wp-content/cache
./wp-content/plugins/wp-rocket/views/cache
./wp-content/themes/Divi/core/components/cache
./wp-content/wphb-cache

Add the following to your .gitignore file

# .gitignore

# any folders named cache or .cache (case insensitive)
[Cc]ache
**/[Cc]ache
**/.[Cc]ache

# any folders named *-cache or *-Cache (e.g. wphb-cache, et-cache)
*-[Cc]ache
**/*-[Cc]ache
**/.*-[Cc]ache
  • [Cc] match both lower and uppercase (i.e. Cache and cache folders)
  • ** matches 0 or more levels of subdirectory. ** is supported as of 1.8.2

Make sure git removes the folder if it was already added and stops tracking it.

1git rm -r --cached .
2git add .
3git commit -m "Update .gitignore"