Mike Williamson
Mike Williamson

Reputation: 3198

How can I generate the .git *FILE* and how is it (de)constructed?

This is not a question about the hidden .git folder!!

My Understanding

I typically use GitHub for most of my Git work. When working with the remote server, I might have my push and fetch configured as such:

$git remote -v
origin  [email protected]:<my_org>/<my_repo>.git (fetch)
origin  [email protected]:<my_org>/<my_repo>.git (push)

The question here is specifically about that <my_org>/<my_repo>.git file.

I know that it "contains" all of the machinery required for a repository: the files, the index, hooks, references, etc. I have been "imagining" that it is a hierarchical zip file that is essentially just the entire repository as it would look locally if I were to zip it all up.

My Questions

  1. Is my understanding correct? Is the <blah>.git file just a zip of the repository? How do I generate it?
  2. What does git do in order to construct / deconstruct it, each time I either git init and git push or each time I git clone? (Is this really just a zipping and unzipping?)
  3. Is there any way to create this structure myself? E.g., is this how GitHub does it on their end (more or less)?
    • And can I use that same git init -g command or something similar to create a .git file.
  4. Where is the documentation on this <blah>.git file (beyond the link above)?
    • I did search for a little while, but everything on ".git" turns up the hidden directory, not the file.
  5. If I create this <blah>.git file on my machine, can others then use my machine as a remote repository?
    • Put another way, how would I create a machine and a file/folder structure to act like a remote repository for someone else?

Upvotes: 1

Views: 904

Answers (1)

VonC
VonC

Reputation: 1324757

No: repo.git it is a folder representing a bare repository (no working tree, just the repo files)

The compression/decompression only occurs for delta encoding of the pack files, which are then transmitted during clone/pull/push.

If you want to build only one "zip" file, see git bundle, which produces a full Git repo as one file.

Upvotes: 2

Related Questions