Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When doing a git clone --mirror where are the actual files?

I have a project on github which I'd like to mirror on my server.

I've tried the following: git clone --mirror [email protected]:user/repo.git.

Then in the repo.git directory, I have the following file structure (eg, output of ls):

FETCH_HEAD branches/ description info/ packed-refs HEAD config hooks/ objects/ refs/

So my question is: where are my files!? It looks like there's a bunch of git related stuff, but I just can't find the code I've written. Am I missing something obvious?

Btw, git status returns fatal: This operation must be run in a work tree but git branch returns the branches. Weird.

like image 990
cpa Avatar asked Mar 07 '13 15:03

cpa


People also ask

Where do files go when you git clone?

git clone is primarily used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location. The original repository can be located on the local filesystem or on remote machine accessible supported protocols. The git clone command copies an existing Git repository.

What does git clone mirror do?

A clone copies the refs from the remote and stuffs them into a subdirectory named 'these are the refs that the remote has'. A mirror copies the refs from the remote and puts them into its own top level - it replaces its own refs with those of the remote.

What does it mean to mirror a repository?

Last modified: 12 August 2022. Repository mirroring in Space allows you to create and maintain a synchronized copy of a repository hosted outside of Space. Mirrored repositories are synchronized in both directions. You can push commites to your Space mirror and they will be delivered to the remote repository.

Does git clone create a folder?

The standard approach to clone is repository is using the git-clone command. But when you simply clone a repository with git clone <repository> , it creates a new directory with repository name at the current path in the file system and clones the repository inside it.


1 Answers

When you git clone --mirror, it produces a bare repository, so it won't have a work area. I use --mirror more often to make a read-only clone of my working repo for others to pull from.

It sounds like you probably should just omit the --mirror option.

From the git clone man page:

--mirror
Set up a mirror of the source repository. This implies --bare. Compared to --bare, --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository.

To be fully clear, the bare, mirror repo does have the entire content of the repository that it was cloned from, but it does not have a work area where you can see these files. If you cloned from your mirrored clone (git clone /path/to/local/mirror_repo.git), you would get the work tree in that new, non-bare repo.

like image 110
Mike Seplowitz Avatar answered Oct 05 '22 04:10

Mike Seplowitz