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?

- 1,015
- 2
- 10
- 29
-
1What do you mean, "`clone` seems to require a `
.git` file"? Are you attempting to do a clone and getting an error message? – Kyle Strand Jan 07 '17 at 07:04 -
1The words in `<>` (triangle brackets) usually refer to some unavoidable parameter or result. In this case when you initialize bare repository you will get something like `
.git` **folder**, where `project` is just a name of your project, it might be any word, words, ... – 0andriy Jan 07 '17 at 10:00 -
I neglected to mention that what I actually want to do is set up a clone on a network (NFS) share and sync the two repositories. Maybe I should just use `rsync`. – Tom Russell Mar 03 '17 at 18:25
3 Answers
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.

- 1,262,500
- 529
- 4,410
- 5,250
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.

- 6,138
- 1
- 24
- 41
seems like you're trying to host a git server

- 3,563
- 3
- 24
- 37
-
The thought had crossed my mind. But I think it's overkill for my immediate purposes. – Tom Russell Jan 07 '17 at 18:38