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?

  • Dropping older Git commits from history?
  • Why is git apply not finding the file to patch in the current directory?
  • Git: Default all text files to unix line breaks
  • How do I create a master branch in a bare Git repository?
  • How Publisher publish message to topic in Apache Kafka?
  • If git commit messages written in the imperative, how do I clarify what hasn't yet been done? 'Don't add hashing' or 'Didn't/Doesn't add hashing'?
  • How do I separate a commit into a branch after doing several other commits?
  • Is it possible to make an existing git commit appear as a merge?
  • Show commit size in git log
  • GIT manages file by storing diff?
  • Git - nullSha1: contains entries pointing to null sha1
  • race conditions if two clients git svn rebase and git push to the same git repo?
  • 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).

    The cat-file command is simply showing you the human-readable version of the object:

    In its first form, the command provides the content

    Git Baby is a git and github fan, let's start git clone.