ffff
ffff

Reputation: 3070

Are the contents of git blob encrypted?

I am reading about the git internals and it says that a blob just contains the content of the file. So I went on doing the following

echo "hello world" > a.txt
git add a.txt

The .git/object had a folder 3b18e512dba79e4c8300dd08aeb37f8e728b8dad. Upon opening it, there was junk value in it. But running the following command,

git cat-file -p 3b18e512dba79e4c8300dd08aeb37f8e728b8dad
// hello world

So the cat-file command is definitely knowing how to parse the blob object. What is that junk value in the blob and how does cat-file interpret it. I'm sure it is the content of the file, but in what format is it written as?

Upvotes: 2

Views: 727

Answers (2)

0xAX
0xAX

Reputation: 21837

In a case of blobs, its content represents blob header and content. You can check this with:

$ openssl zlib -d -in .git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad
blob 12hello world

for example.

Upvotes: 4

JeremiahB
JeremiahB

Reputation: 916

In git a blob is the content of a file. All blobs are compressed with zlib and delta compression in git (so revisions don't eat up massive amounts of space), which is why blobs are unreadable. The name of a blob is its SHA-1 hash.

Upvotes: 1

Related Questions