Where does the file <project>.git come from?

1.1k Views Asked by At

I've initialized several local git repos but none of them have a <project>.git file; only a .git directory. I would like to clone one of these repos to another machine on the local network, but clone seems to require a <project>.git file. How does this file get generated?

3

There are 3 best solutions below

0
On BEST ANSWER

To have a project.git (and not a project/.git), you would need to use git clone --bare or git init --bare.

That would create a bare repository, one with only the .git content and no working tree.

0
On

If you just need to copy the project to some other machine with all the files and git data in it then just copy the folder you have with .git repository. .git directory contains git's metadata (and all version history). This will have the complete working tree of your project with git version history. This is called non bare repository.

A non-bare repository is a clone of another repository, plus local state, such as .git/HEAD, which indicates which revision is checked out, the index, which is used to identify what has changed in the checked out tree and to help prepare commit objects, etc.

A bare repo is project.git which doesn't include the working tree and just the .git folder. A bare repository created with git init --bare or git clone --bare is for sharing basically. If you are collaborating with a team of developers, and need a place to share changes to a repo, then you will may create a bare repository in centralized place where all users can push their changes.

So if you need a bare repo i.e., project.git you will need to create one. The project.git or .git folder inside the directory is same which contains the git metadata and version history.

1
On

seems like you're trying to host a git server

git documentation to setup git server