Search code examples
gitsshsshfs

git clone --bare from ssh: objects folder empty


I have a working directory on a server, which I can access either with interactive ssh or mounting my home with sshfs, and I would like to create a bare repository to start sharing it.

Doing

git clone --bare mount_point/path

and

git clone --bare ssh://user@server/path

give two different results. In particular, the main difference is in the objects folders. The first one has 00, 0b, ... subfolders and certain files in the pack subfolder. The second one instead has only info and pack, and the files in pack are different from the first case. As a consequence the sizes of the two cloned bare repos are different.

Though, on both I can successfully do either git log or, for instance, git diff.

Can anybody tell me what is happening? Could it be that git-clone over ssh compresses more the objects in the repository? Or am I losing information somewhere?

Thank you very much


Solution

  • git optimizes cloned repository storage when it deals with repositories on the same volumes/same coputers. Look at --no-hardlinks, --local, etc options of git clone --help. Actually it's possible to force it make a "real copy" but usually you don't need to.

    Update: Ok, no hardlinks. Before network transfer git packs objects, missing on the receiving side, and these packs are stored as they received, without unpacking. git gc does the same. .git/objects/pack/ contains packed objects, as name suggests. To view contents of a particular pack file use git verify-pack -v .git/objects/pack/pack-<smth>.idx. Check this doc for a tutorial.