1

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  git@github.com:<my_org>/<my_repo>.git (fetch)
origin  git@github.com:<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?
Mike Williamson
  • 4,915
  • 14
  • 67
  • 104
  • 1
    Your question seems pretty broad, but if you just want to copy a repository to a new location, all you need to do is copy the `.git` folder and that is all. – Tim Biegeleisen Mar 06 '17 at 01:31
  • 1
    .git is a directory. It's by default the name of a bare git repository. `git init --bare .git` – ElpieKay Mar 06 '17 at 01:54
  • 1
    As @ElpieKay said, it's not a file, it's a directory. The contents of bare repository `foo.git` match the contents of `.git` in non-bare repository `foo`, except that the `config` file has `core.bare` set to `true`. (But the best way to set it up from an existing non-bare clone is to `git clone --bare`, and perhaps set `core.shared` as well.) To use it as a server, your machine must allow some kind of access, whether that's ssh, http, via the `git://` protocol, or whatever. – torek Mar 06 '17 at 02:26
  • Oops, I should have said `core.sharedRepository` (it has been a long time since I set up Git servers). – torek Mar 06 '17 at 02:44
  • Thanks to all of you for the information, but I think you were misunderstanding my point. At **some point** `.git` ***IS*** a file, not a directory. My link embedded in the question and VonC's answer below may help you to better understand. (There is still much I don't understand, of course, hence my question. But I did understand that this is at some point **also** an archive-like file, and not just a directory structure.) – Mike Williamson Mar 15 '17 at 03:32

1 Answers1

2

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    On bare repo: https://raw.githubusercontent.com/sitaramc/git-notes/6ab1eada80d7c7a676cbd94a5d58f556634d794b/concepts-and-tips/bare.notes, https://github.com/sitaramc/git-notes/blob/cb3ac8bcb85f7d11bb45aa89becd90c8b4738bf1/concepts-and-tips/0-terminology.notes – VonC Mar 06 '17 at 20:43