Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6866969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:15:01+00:00 2026-05-27T03:15:01+00:00

Is there any documentation on how Git stores files in his repository? I’m try

  • 0

Is there any documentation on how Git stores files in his repository? I’m try to search over the Internet, but no usable results. Maybe I’m using incorrect query or maybe this is great secret — Git repository internal format?

Let me explain, why I need this rocket science information: I’m using C# to get file history form repository. But in libgit2sharp library it’s not implemented currently. So (as a responsible person 😉 I need to implement this feature by myself and contribute to community.

But after moving kernel sources to github I’m even don’t know where start to my search.

Many thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:15:01+00:00Added an answer on May 27, 2026 at 3:15 am

    The internal format of the repository is extremely simple. Git is in essence a user space file system that’s content addressable.

    Here’s a thumbnail sketch.

    Objects

    Git stores its internal data structures as objects. There are four kinds of objects: blobs (sort of like files), trees (sort of like directories), commits (snapshots of the file system at particular points in time along with information on how to reach there) and tags (pointers to commits useful for marking important ones).

    If you look inside the .git directory of a repository, you’ll find an objects directory that contains files named by the SHA-1 hash. Each of them represents an object. You can inspect them using plumbing git cat-file command. An example commit object from one of my repositories

    noufal@sanitarium% git cat-file -p 7347addd901afc7d237a3e9c9512c9b0d05c6cf7
    tree c45d8922787a3f801c0253b1644ef6933d79fd4a
    parent 4ee56fbe52912d3b21b3577b4a82849045e9ff3f
    author Noufal Ibrahim <noufal@..> 1322165467 +0530
    committer Noufal Ibrahim <noufal@..> 1322165467 +0530
    
    Added a .md extension to README
    

    You can also see the the object itself at .git/objects/73/47addd901afc7d237a3e9c9512c9b0d05c6cf7.

    You can examine other objects like this. Each commit points to a tree representing the file system at that point in time and has one (or more in case of merge commits) parent.

    Objects are stored as single files in the objects directory. These are called loose objects. When you run git gc, objects that can no longer be reached are pruned and the remaining are packed together into a a single file and delta compressed. This is more space efficient and compacts the repository. After you run gc, you can look at the .git/objects/pack/ directory to see git packfiles. To unpack them, you can use the plumbing command git unpack-objects command. The .git/objects/info/packs file contains a list of packfiles that are currently present.

    References

    The next thing you need to know is what references are. These are pointers to certain commits or objects. Your branches and other such things are implemented as references. There are two kinds “real” (which are like hard links in a file system) and “symbolic” (which are pointers to real references – like symbolic links).

    These are located in the .git/refs directory. For example, in the above repository, I’m on the master branch. My latest commit is

    noufal@sanitarium% git log -1
    commit 7347addd901afc7d237a3e9c9512c9b0d05c6cf7
    Author: Noufal Ibrahim <noufal@...>
    Date:   Fri Nov 25 01:41:07 2011 +0530
    
        Added a .md extension to README
    

    You can see that my master reference located at .git/refs/heads/master points to this commit.

    noufal@sanitarium% more .git/refs/heads/master
    7347addd901afc7d237a3e9c9512c9b0d05c6cf7
    

    The current branch is stored in the symbolic reference HEAD located at .git/HEAD. Here it is

    noufal@sanitarium% more .git/HEAD
    ref: refs/heads/master
    

    It will change if you switch branches.

    Similarly, tags are references like this too (but they are not movable unlike branches).

    The entire repository is managed using just a DAG of commits (each of which points to a tree representing the files at a point in time) and references that point to various commits on the DAG so that you can manipulate them.

    Further reading

    • I have a presentation which I use for my git trainings up here that explains some of this.
    • The community book at http://book.git-scm.com/ has some sections on the internals.
    • Scott Chacon’s Pro Git book has a section on internals
    • He also has a peepcode PDF just about the internals.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any version of git documentation in chm format? I know that I
Is there any documentation\code on the file format used by CorelDraw CDR files? I'm
Is there any documentation about internal structure of Git index file? From various book
Is there any documentation on cross thread communication in Delphi? How can I send
Is there any documentation about introducing jBoss seam to an old Hibernate/JSF project? Have
Is there any clear documentation on the binary formats used to serialize the various
Is there any good documentation on implementing new refactorings in Eclipse? Specifically, I'd like
Beyond the official documentation, are there any recommended resources for learning to build jQuery
I'm seeing conflicting references in Oracles documentation . Is there any difference between how
I'm wondering if there is any shortcut in visual studio to generate automatic documentation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.