GIT-PRUNE(1)

πŸ’… GIT-PRUNE(1) β€” like, the git-prune page from the Git Manual, bestie

okay so picture this: you're deep in the Git Manual, section GIT-PRUNE(1), and you need to know how to yeet unreachable objects out of the object database. that's the whole gig. let's get into it πŸŽ€


✨ NAME ✨

git-prune β€” prune all unreachable objects from the object database. yes, it's literally in the name, she's not subtle πŸ’β™€οΈ


πŸ¦‹ SYNOPSIS πŸ¦‹

git prune [-n] [-v] [--progress] [--expire <time>] [--] [<head>...]

🌸 DESCRIPTION 🌸

πŸ’– Note: in most cases, users should run git gc, which calls git prune. see the section "NOTES", below. (like, seriously, go look. it's right there. i'm not joking.)

so what does this actually do? it runs git fsck --unreachable using all the refs available in refs/, optionally with an additional set of objects specified on the command line, and then prunes all unpacked objects unreachable from any of these head objects from the object database. iconique behaviour honestly ✨

on top of that, it prunes the unpacked objects that are also found in packs by running git prune-packed. she's thorough. she does the work. and it also removes entries from .git/shallow that are not reachable by any ref. slay cleanup crew 🧹

⚠️ heads up, bestie: unreachable, packed objects will remain. if this is not desired, see git-repack(1). don't come for me, i'm just the messenger 😭

πŸ‘‘ OPTIONS πŸ‘‘

  • -n, --dry-run β€” do not remove anything; just report what it would remove. it's giving window shopping πŸ›οΈ
  • -v, --verbose β€” report all removed objects. she's a talker and we love her πŸ—£οΈ
  • --progress β€” show progress. so you can watch the little bar do its thing 🫢
  • --expire <time> β€” only expire loose objects older than <time>. ageism but make it garbage collection ⏳
  • -- β€” do not interpret any more arguments as options. the classic "we're done with flags now" boundary line 🚧
  • <head>... β€” in addition to objects reachable from any of our references, keep objects reachable from listed <head>s. protect them, they're main characters πŸ’œ

🌈 EXAMPLES 🌈

to prune objects not used by your repository or another that borrows from your repository via its .git/objects/info/alternates:

$ git prune $(cd ../another && git rev-parse --all)

copy it exactly, bestie, every character. no cap 🎯


πŸ”₯ NOTES πŸ”₯

in most cases, users will not need to call git prune directly, but should instead call git gc, which handles pruning along with many other housekeeping tasks. she's the whole package. the moment. the icon πŸ‘‘

for a description of which objects are considered for pruning, see git fsck's --unreachable option. iykyk πŸ’«


⭐ SEE ALSO ⭐


🧚 GIT 🧚

part of the git(1) suite. royalty, obviously πŸŒˆπŸ‘‘


k that's the whole page, bestie πŸ’– this glorious little manual is brought to you by Git 2.56.0, dated 2026-09-27 β€” and that's the vibe check, signed off with love, GIT-PRUNE(1) out πŸŽ€βœ¨

πŸ“¦ where this page comes from