3

Why is it that

git clone --mirror [repo-url]

or

git clone --mirror --recursive [repo-url]

will not work with submodules. Trying to git fetch --recurse-submodules gives the error

fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository

Excluding --mirror however does work.

So if the repository has been cloned with --mirror option, there is no way to bring the submodules in, unless the repository is cloned without --mirror.

Running git submodule update --init --recursive from the working copy gives the error message:

fatal: Not a git repository (or any of the parent directories): .git

Running git submodule init from the mirrored repository gives this error message:

fatal: /usr/libexec/git-core/git-submodule cannot be used without a working tree.

Using GIT_WORK_TREE and/or GIT_DIR environment variables also does not work.

Is the only option to clone the repository from scratch again?

Edit: By the way, the reason for --mirror in the first place was because I was following this: http://jonathannicol.com/blog/2013/11/19/automated-git-deployments-from-bitbucket/

Mark Aroni
  • 605
  • 1
  • 10
  • 21

1 Answers1

2

The repository you create with --mirror flag is a bare repository (i.e. it does not have a working area). AFAIK, submodules can be initialized and downloaded only into working area.

More:

Community
  • 1
  • 1
fracz
  • 20,536
  • 18
  • 103
  • 149
  • After creating the repository I would run `cd ~/.git GIT_WORK_TREE=/home//www git checkout -f production` and still cannot get the submodules from the working area or repo directories. It seems strange that by cloning a repository in this way that submodules cannot be gotten at a later time. Surely it is possible, what am I doing wrong? – Mark Aroni May 25 '16 at 15:29
  • Thanks for your help, from your link, this solution worked for me: http://stackoverflow.com/a/31627058/644721 – Mark Aroni May 25 '16 at 15:47