GH-CACHE-DELETE(1)

๐Ÿ—‘๏ธโœจ GH-CACHE-DELETE (1) โ€” the GitHub CLI manual, bestie edition โœจ๐Ÿ—‘๏ธ

okay so this is the manual page for gh-cache-delete from the GitHub CLI manual, and I'm gonna walk you through it like we're texting at 1am ๐Ÿ’–


๐Ÿ’… NAME ๐Ÿ’…

gh-cache-delete โ€” Delete GitHub Actions caches. that's it, that's the whole vibe ๐ŸŽ€


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

gh cache delete [<cache-id> | <cache-key> | --all] [flags]

so you give it either a cache id, or a cache key, or --all, plus whatever flags you want. pick your fighter, bestie ๐Ÿซถ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

Delete GitHub Actions caches. that's literally the whole job, and it ate ๐Ÿ’…

but real talk โ€” deletion requires authorization with the repo scope. no scope, no slay. periodt ๐Ÿ”ฅ


โœจ OPTIONS โœจ

  • -a, --all โ€” Delete all caches. yep, ALL of them ๐Ÿ˜ญ can be used with --ref to delete all the caches for one specific ref, which is lowkey the move if you don't wanna nuke everything.
  • -r, --ref <string> โ€” Delete by cache key and ref, formatted as refs/heads/ or refs/pull//merge. so you're matching on key + ref together, got it ๐Ÿงš
  • --succeed-on-no-caches <--all> โ€” Return exit code 0 if no caches found. cute, right? BUT it must be used in conjunction with --all โ€” like, it does not work solo, it needs its buddy ๐Ÿ™ˆ

๐Ÿ”ฎ OPTIONS INHERITED FROM PARENT COMMANDS ๐Ÿ”ฎ

  • -R, --repo <[HOST/]OWNER/REPO> โ€” Select another repository using the [HOST/]OWNER/REPO format. classic parent-command energy ๐Ÿ‘‘

โญ EXIT CODES โญ

  • 0: Successful execution โ€” icon status ๐ŸŒˆ
  • 1: Error โ€” it's giving oops ๐Ÿ’€
  • 2: Command canceled โ€” you (or something) hit the brakes
  • 4: Authentication required โ€” log in, bestie ๐Ÿ˜ญ
NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information. (yes, that's a real note, go check the help fr fr)

๐Ÿ“ EXAMPLE ๐Ÿ“

here's the part where it gets iconic โ€” every single example, untouched, exactly as written:

# Delete a cache by id
$ gh cache delete 1234

# Delete a cache by key
$ gh cache delete cache-key

# Delete a cache by id in a specific repo
$ gh cache delete 1234 --repo cli/cli

# Delete a cache by key and branch ref
$ gh cache delete cache-key --ref refs/heads/feature-branch

# Delete a cache by key and PR ref
$ gh cache delete cache-key --ref refs/pull/<PR-number>/merge

# Delete all caches (exit code 1 on no caches)
$ gh cache delete --all

# Delete all caches for a specific ref
$ gh cache delete --all --ref refs/pull/<PR-number>/merge

# Delete all caches (exit code 0 on no caches)
$ gh cache delete --all --succeed-on-no-caches

see how --succeed-on-no-caches flips that exit code from 1 to 0? that's the whole plot twist ๐ŸŽฌโœจ


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

  • gh-cache(1) โ€” the parent, the main character, the source of all the inherited flags ๐Ÿซถ

k bye bestie, go clear those caches ๐Ÿ’– this was GitHub CLI v2.102.0, dated Oct 2026 โ€” mwah, signed sealed delivered and prettier than the original ngl ๐ŸŽ€โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from