Git/Internal structure

      Naked git structure

      The following is an freshly initialized git v1.5.2.5 repository.[1]

      .
      └── .git/
          ├── HEAD
          ├── branches/
          ├── config
          ├── description
          ├── hooks/
          │   ├── applypatch-ms
          │   ├── commit-msg
          │   ├── post-commit
          │   ├── post-receive
          │   ├── post-update
          │   ├── pre-applypatc
          │   ├── pre-commit
          │   ├── pre-rebase
          │   └── update
          ├── info/
          │   └── exclude
          ├── objects/
          │   ├── info/
          │   └── pack/
          └── refs/
              ├── heads/
              └── tags/
      

      Files

      HEAD

      HEAD indicates the currently checked out code. This will usually point to the branch you're currently working on.

      You can also enter what git calls a "detached HEAD" state, where you are not on a local branch. In this state the HEAD points directly to a commit rather than a branch.

      config

      The configuration file for this git repository. It can contain settings for how to manage and store data in the local repository, remote repositories it knows about, information about the local user and other configuration data for git itself.

      description

      Used by repository browser tools - contains a description of what this project is. Not normally changed in non-shared repositories.

      Folders

      branches

      hooks

      Contains scripts to be run when particular events happen within the git repository.

      Hooks would be used, for example, to run tests before creating each commit, filter uploaded content, and implement other such custom requirements.

      info

      objects

      This is where all the files, directory listings, commits and such are stored.

      There are both unpacked objects in numbered directories under this, and "packs" containing many compressed objects within a pack directory. The uncompressed objects will periodically be collected together by automatic "git gc" runs in to packs.

      refs

      This contains the information about which branches point where. It normally contains a "heads" directory for your local branches and a "remotes" directory for your copies of remote branches. Not all branches are within these directories - branches which have not changed recently may be found in the file .git/packed-refs .


      Footnotes

      1. ^ Generated with tree v1.5.1.1 using tree -AnaF.

      Read in another language

      This page is available in 1 language

      Last modified on 27 May 2012, at 14:21