Why can't I view a git object in an ordinary file editor?
When I run
git cat-file -p <hash>, I get the content of this object printed rather nicely. When I’m looking for that file in the
.git-directory manually and open it in my file editor (like notepad), I get only garbage.
Why is that?
One Solution collect form web for “Why can't I view a git object in an ordinary file editor?”
This is because Git compresses objects (blobs) for storage and you are looking at the compressed version when you open the file directly in an editor:
Git compresses the new content with zlib
zlib is a:
general purpose data compression library
Also from zlib’s Wikipedia page:
The Git version control system uses zlib to store the contents of its
data objects (blobs, trees, commits and tags).
cat-file command is simply showing you the human-readable version of the object:
In its first form, the command provides the content