2

I have tried to setup Gitolite mirroring concept and everything is working fine except submodule.

When I clone repo (which has submodules) from slave server and update the submodules, the submodules are cloned from master server.

How to make those submodules also clone from slave server?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Seenivasan
  • 101
  • 1
  • 2

1 Answers1

2

One way would be, for instance in a post-receive hook, to make sure the .gitmodules reflects the adequate submodules addresses, by changing those submodules addresses, followed by a git submodule sync.

Or, See "Git submodule url changed" and the new command (Git 2.25+, Q1 2020)

git submodule set-url [--] <path> <newurl>

maxmelbin objects:

but changing .gitmodules means a new commit - right?

Not necessarily: you could make that modification and not commit it, keeping it purely "private" (local to your slave server).

Question was that since all repo's are mirrored in the slave, is there a way to automatically pick the local repo url during a submodule update, regardless of which sites url was configured in .gitmodules for that commit has

I think the --reference parameter of the git submodule update command could achieve just that.

--reference <repository>

This option is only valid for add and update commands.
These commands sometimes need to clone a remote repository. In this case, this option will be passed to the git-clone(1) command.
NOTE: Do not use this option unless you have read the note for git-clone's --reference and --shared options carefully.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • but changing .gitmodules means a new commit - right? Question was that since all repo's are mirrored in the slave, is there a way to automatically pick the local repo url during a submodule update, regardless of which sites url was configured in .gitmodules for that commit hash. – maxmelbin Aug 23 '12 at 06:58
  • @maxmelbin no: you could make that modification and not commit it, in order for it to be "private" to your slave server. I have edited my answer to address your full comment. – VonC Aug 23 '12 at 07:36