amar
amar

Reputation: 33

Where does git daemon store files

I am working on Centos5 machine where i created the empty bare repository using command

$ mkdir test_repo.git
$ cd test_repo.git
$ git --bare init

It contains only git-metadata. then I started git daemon on same system using command

$  git daemon --reuseaddr --base-path=/data/test_work/ --export-all --verbose --enable=receive-pack

from another machine within LAN I cloned that empty repositry add some files commit it and push to master using command

$ git clone git://<system_ip where git dameon run>/test_repo.git

add and commit some files in it and push to git

$ git push origin master

Then I cloned from another machine it works well I get all the changes which I pushed.

But when I saw the actual test_repo.git in machine where I run git-daemon. It contains only git-meta data where my committed files are saved ?

Please, tell me the location where my actual data save for git-daemon and bare repo? Is it on my machine itself or any other location ?

Upvotes: 0

Views: 1060

Answers (2)

FooF
FooF

Reputation: 4462

Git uses normally .git directory to store the meta data. If you remove everything else than this directory in your work directory, you can still get your committed files back using git checkout.

You created so called bare repository (option --bare). It only contains the .git meta data. It is not meant to be used for working directly, so the files would just waste storage space and updating those files would be useless effort anyway when someone updates the repository. Besides which branch should we checkout anyway if we receive commits to multiple different branches!?! The commits and other git objects are specifically stored under objects/ sub-directory beginning with the first letters of your commit SHA1 (so that for example you can find git object with SHA1 ffee0ccd6cce082784d515a6321a7afbfdc0dde0 in directory objects/ff/ee0ccd6cce082784d515a6321a7afbfdc0dde0) or in objects/pack/ directory in packed format (several objects put in the same highly compressed file to save storage space).

Everything is stored in the bare directory where you commit. Nothing is pushed over the network to some secret mysterious location unless you tell so (and then too the location is not secret but based on what you say in the command line either using direct URL or configured remote name with origin automatically defined to be the repository you originally cloned).

Upvotes: 1

CharlesB
CharlesB

Reputation: 90336

Files are stored in Git object store, and are not visible as is if it is a bare repo. They aren't checked out, there's no working copy, only data & metadata, saved in a binary format to save space and gain speed.

The real data is in the objects/pack directory.

For more info see How git stores your data.

Upvotes: 1

Related Questions