Search code examples
pre-commitpre-commit.com

How to clear the pre-commit caches?


The ~/.cache/pre-commit/ folder is many GB large, how do I clean it?

  • Can I simply delete it?
  • Or at least delete all the files?
  • Or do I have to be selective about it?
  • Is there a command for cleaning it up?

Going into every single repository and executing some command there is not an option:

  • I got a lot of repositories checked out, I'm not going to go through all of them.
  • Some cached data refers to repositories long ago deleted, so there's no place where I could execute a command.

The README file in the folder says:

This directory is maintained by the pre-commit project.
Learn more: https://github.com/pre-commit/pre-commit

However, I cannot find information if and what data can be deleted.


Solution

  • pre-commit has two builtin commands to handle caches:

    both of these are listed in pre-commit --help -- the standard way to ask a tool for what commands / options it supports


    disclaimer: I wrote pre-commit