質問

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

I've tried the following: git clone --mirror git@github.com: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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top