Skip to content

Instantly share code, notes, and snippets.

@ctindall
Forked from mhl/git-show-all-objects.sh
Last active December 11, 2015 10:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ctindall/4588884 to your computer and use it in GitHub Desktop.
Save ctindall/4588884 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
cd "$(git rev-parse --show-cdup)"
# Find all the objects that are in packs:
if [ "$(ls -A .git/objects/pack)" ]
then
for p in .git/objects/pack/pack-*.idx
do
git show-index < $p | cut -f 2 -d ' '
done
fi
# 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,'
@nk9
Copy link

nk9 commented Jun 18, 2014

OS X 10.9's version of sed doesn't understand -r, but awk works just as well for this. I've provided an alternative in my fork.

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