如何在推送到裸露的工作目录之后,在工作树中初始化/更新git子模块? [英] How do I init/update a git submodule in a working tree after pushing to a bare working directory?

查看:92
本文介绍了如何在推送到裸露的工作目录之后,在工作树中初始化/更新git子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接工作树的git存储库,我正在推送到远程的裸露回购站。
存储库包含一个子模块。



在远程端:我检查一个工作树的回购 git checkout -f 设置了 GIT-DIR GIT-WORK-TREE env vars。

在工作树中,我现在可以看到子模块的所有预期文件和一个空目录('MySubmodule')。



然后我做:

  git submodule init 
git子模块更新

这样的错误带有如下信息:

  working tree'../../workTree/'已存在
'git@github.com:user / MySubmodule.git'克隆到子模块路径'MySubmodule'失败

空子模块目录现在也已从工作树消失了......



我不知道我在哪里出错,基本上我只是想检查子模块文件,因为我会用'git submodule update'。 / p>

解决方案

它看起来像当你运行git submodule update时你不能设置GIT_WORK_TREE ...它会尝试使用这是作为子模块的工作树,而不是用于超级项目。



我必须更新服务器更新后的脚本...

  / usr / local / bin / git --git-dir =$ PROJECT_DIR--work-tree =$ PROJECT_DEMOcheckout -f ; 

cd$ PROJECT_DEMO;
/ usr / local / bin / git --git-dir =$ PROJECT_DIR子模块更新--init --recursive;

注意我没有设置env变量,并且子模块命令没有 - 工作树设置...它似乎需要从cwd工作。


I have a git repository with an attached working tree that I'm pushing to a bare repo on a remote. The repository includes a submodule.

At the remote end: I check out the repo to a working tree git checkout -f having set GIT-DIR and GIT-WORK-TREE env vars.

In the working tree I now see all the expected files and an empty directory for the submodule ('MySubmodule').

I then do:

git submodule init
git submodule update

This errors with a message like:

working tree '../../workTree/' already exists
Clone of 'git@github.com:user/MySubmodule.git' into submodule path 'MySubmodule' failed

The empty submodule directory has now also 'vanished' from the working tree...

I'm not sure where I'm going wrong with this, basically I just want to check out the submodule files as I would with 'git submodule update'.

解决方案

It looks like when your running "git submodule update" you can't set the GIT_WORK_TREE... it will try to use this as the working tree for the submodule, not for the super project.

I've had to update my servers post-update script...

/usr/local/bin/git --git-dir="$PROJECT_DIR" --work-tree="$PROJECT_DEMO" checkout -f;

cd "$PROJECT_DEMO";
/usr/local/bin/git --git-dir="$PROJECT_DIR" submodule update --init --recursive;

Notice I didn't set env variables, and that the submodule command did not have the "--work-tree" set... it seems that it needs to work from the cwd.

这篇关于如何在推送到裸露的工作目录之后,在工作树中初始化/更新git子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆