Git:如何在服务器上放置带子模块的非裸仓库?

时间:2016-12-09 21:45:57

标签: git

如何使用子模块获取非裸git repo并使其适合在服务器上安装? (裸)

以下工作均无效:

git clone --bare nonBare bare
git clone --bare --recursive nonBare bare
git clone --recursive nonBare bare; cd bare; git config --bool core.bare true

服务器是git-daemon。

2 个答案:

答案 0 :(得分:0)

在服务器上创建一个裸仓库

mkdir bareRepo.git
cd bareRepo.git
git init --bare

在源非裸仓库

git push --mirror <bareRepo.git URL>

答案 1 :(得分:0)

事实证明,存在多个问题。鉴于git-daemon服务器不支持与我拥有的repo相同的子模块表示,我决定将每个子模块视为一个单独的repo。我必须处理的一个问题是,由于现有的repo有一个我无法访问的服务器的遥控器,我不得不为新服务器创建新的遥控器。当进行git推送时,只推送当前分支,而不是所有(旧的)远程跟踪分支。

为了迁移,我写了一个脚本,它执行了以下操作:

for every submodule, created a destination directory and did a "git init --bare" in it
for every submodule
  for every branch in the submodule, do a "git checkout <branch>"
  do a "git push --mirror <destination Directory>