Show contents of all git objects in a git repo

find .git/objects/ -type f \| sed 's/\.git\/objects\/\///' | sed 's/\///g' | xargs -n1 -I% echo echo "%" \$\(git cat-file -p "%"\) \0 | xargs -n1 -0 sh -c
This script finds all git objects and `git cat-file`'s their content. This is really just a helper function to play around with the internals of git repositories. See https://git-scm.com/book/en/v2/Git-Internals-Git-Objects of more info.
Sample Output
$ mkdir test1; cd test1; git init
$ echo hello | git hash-object --stdin -w
ce013625030ba8dba906f756967f9e9ca394464a

$ cd ..; git clone test1 test2; cd test2

# now we run the command and notice
# the objects have been cloned
$ find .git/objects/ -type f \| sed 's/\.git\/objects\/\///' | sed 's/\///g' | xargs -n1 -I% echo echo "%" \$\(git cat-file -p "%"\) \0 | xargs -n1 -0 sh -c
4b825dc642cb6eb9a060e54bf8d69288fbee4904
ce013625030ba8dba906f756967f9e9ca394464a hello

0
By: wires
2020-11-15 09:24:58

What Others Think

Just use the pipe char in §sed§ under most circumstances instead of forward slash cuz you most likely need to escape more forward slashes than pipes. Plus it makes it much more readable and coherent.
rautamiekka · 2 weeks and 3 days ago
Do you sometimes have trouble writing an essay, or is it just that inspiration leaves you and you still need to write? I offer assignment help and you will see that this is the best service.
Otharei · 2 weeks and 2 days ago
I am the cofounder at CIPD writer Jordan and I am looking for a complete guide for coding, I want to learn how to develop a website in a professional way for my business and coming up ventures that I am planning. I need help, is there any expert? Or a teacher who can guide me thoroughly.
alicemorgan · 2 weeks ago
Really, this article is to a great degree one of the most flawlessly awesome ever [url=https://free-cell.co/]freecell[/url]
Selenagobella · 1 week and 5 days ago
it doesn't work. are there any other script? fencingsacramentoca.com
looneyhans · 1 week and 2 days ago
nice it really works! bathroomremodelcedarrapids.com
Killersmile · 6 days ago
Thanks for sharing this information with us, I really admire such platforms that offer valuable information that is not available anywhere else. I am a blogger employed at guardians of the galaxy shop, offering writing services at affordable rates, if you want us to write your web content comment below.
alicemorgan · 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: