Skip to content

Instantly share code, notes, and snippets.

@mhl
Created September 12, 2011 16:05
Show Gist options
  • Save mhl/1211638 to your computer and use it in GitHub Desktop.
Save mhl/1211638 to your computer and use it in GitHub Desktop.
A script to show all the objects in a git repository
#!/bin/sh
set -e
cd "$(git rev-parse --show-cdup)"
# Find all the objects that are in packs:
for p in .git/objects/pack/pack-*.idx
do
git show-index < $p | cut -f 2 -d ' '
done
# And now find all loose objects:
find .git/objects/ | egrep '[0-9a-f]{38}$' | \
sed -r 's,^.*([0-9a-f][0-9a-f])/([0-9a-f]{38}),\1\2,'
@ctindall
Copy link

There's a problem with this script if there are no packfiles in the repository where you use it. I've fixed it in my fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment