推送到裸工作目录后,如何初始化/更新工作树中的 git 子模块?
我有一个带有附加工作树的 git 存储库,我将其推送到远程上的裸存储库。 该存储库包括一个子模块。
在远程端:我将存储库签出到设置了 GIT-DIR
和 GIT- 的工作树
环境变量。git checkout -f
WORK-TREE
在工作树中,我现在看到所有预期的文件和子模块的空目录(“MySubmodule”)。
然后我这样做:
git submodule init
git submodule update
这个错误,消息如下:
working tree '../../workTree/' already exists
Clone of '[email protected]:user/MySubmodule.git' into submodule path 'MySubmodule' failed
空的子模块目录现在也从工作树中“消失”了...
我不确定我在哪里出了问题,基本上我只是想检查一下子模块文件,就像我使用“git submodule update”一样。
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 '[email protected]: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'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来当您运行“git submodule update”时,您无法设置 GIT_WORK_TREE ...它会尝试使用它作为子模块的工作树,而不是超级项目的工作树。
我必须更新我的服务器更新后脚本...
请注意,我没有设置环境变量,并且子模块命令没有设置“--work-tree”...似乎它需要来自 Cwd 的工作。
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...
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
,将bare = true
更改为bare = false
>.git/config 然后执行git checkout
。First of all, why do you need to checkout a bare repo? Just clone it somewhere else and work with a normal, non-bare repo.
But if you really need to do it, you can rename the folder to
.git
, changebare = true
tobare = false
in.git/config
and then dogit checkout
.