Search notes:

.git (Git repository directory)

The .git directory contains the revision history of a repository.

Initial files and directories

The GIT directory is created with the git init command.
This command will create the following files and subdirectories
git init will also copy the content of so-called template directory into the GIT directory.

Determine location of git dir

The absolute location of a working tree's git directory can be determined with
git rev-parse --git-dir
See also Determine interesting directories of a working tree.

Structure

Some files and directories that might be found in the GIT-directory include:
|   CHERRY_PICK_HEAD               | Records the commits that are being cherry-picked when executing 'git cherry-pick'
│   COMMIT_EDITMSG
│   config
│   description
│   FETCH_HEAD                     | The branch (and commit id?) of the remote repository from which the last 'git fetch' retrieved objects.
│   HEAD                           | The commit on which the changes in the working tree are based
│   index
|   MERGE_HEAD                     | Records the commits that are being merged by 'git merge' (Not available before executing git merge)
│   ORIG_HEAD                      | Value of HEAD before executing «drastic» commands so as to be able to undo the changes of such commands
│   packed-refs
|   pid                            | Process id of webserver if using gitweb?
│  
├───branches                       | (slightly) deprecated directory to store shorthands for URLs for git fetch, git pull and git push
├───gitweb                         | Used for «gitweb». Created, for example(?), when running git instaweb
│   │   gitweb_config.perl
│   │   lighttpd.conf              | lighttpd configuration file
│   │
│   ├───lighttpd
│   │       error.log
│   │
│   └───tmp
├───hooks                          | Scripts to be invoked when certain events occur in a repository.
├───info
│       exclude
├───logs                           | Records changes to refs.
│   │   HEAD
│   │
│   └───refs
│       ├───heads
│       │       nameOfBranch       | Records changes to tip of branch named 'nameOfBranch'
│       ├───remotes
│       │   └───NameOfRemote       | A typical name for NameOfRemote remote is 'origin'
│       │       └───feature
│       │           └───version1
│       └───remotes
├───objects
│   ├───xx                         | xx are two hexadecimal characters, git object whose SHA-1  start with xx are stored under this directory
│   ├───info
│   └───pack
├───refs
│   ├───heads
│   │   └───remotes
│   ├───remotes
│   │   └───NameOfRemote           | Another remote
│   │       └───feature
│   │           └───version1
│   └───tags
│           rel.1.1
│           rel.1.2
│           rel.2.0
└───remotes                        | Lecacy way to store shorthands for URLs and default refnames to be used for interaction with «remote» repositories.

Determining the .git directory

git rev-parse --git-dir
git rev-parse --absolute-git-dir

Finding files in git repository with find

In order to find files in a git repository with find, the directory ./.git can be excluded with -prune.

GIT_DIR environment variable

If the environment variable GIT_DIR is set, its value determines the location of the .git directory.

See also

The core.repositoryformatversion option.
The --git-dir command line option.

Index