gpt4 book ai didi

git - git 是否允许 "bare"子模块?

转载 作者:太空狗 更新时间:2023-10-29 13:40:54 26 4
gpt4 key购买 nike

这可能很糟糕,我不确定。

假设我们有一个带有工作目录的 repo “产品”

/product
/product/command.script
/product/config/ (bare git repo)

还有一个带有工作目录的 repo “配置”

/config
/config/config.json

command.script 文件具有与裸仓库交互的操作。前任。运行 command.script BRANCH1 将运行命令

git show BRANCH1:config.json

有什么方法可以让“/product/config/”文件夹成为“product”repo 的子模块,这样当克隆“product”repo 时,“config”repo 也将被克隆

git clone --bare [config origin here] config

从它的来源,当“product”repo 被获取时,“/product/config”子模块可以被获取

git fetch origin '*:*'

或者这是否应该通过某种钩子(Hook)来处理?

最佳答案

否:当获取 repo “产品”时,其索引将包含 gitlink (special entry recording the SHA1 of the submodule) .

该条目只能在非裸仓库中使用,以便作为嵌套(子模块)仓库进行扩展。

这就是为什么 git clone man page提及:

--recursive
--recurse-submodules

After the clone is created, initialize all submodules within, using their default settings. This is equivalent to running git submodule update --init --recursive immediately after the clone is finished.
This option is ignored if the cloned repository does not have a worktree/checkout (i.e. if any of --no-checkout/-n, --bare, or --mirror is given)


这意味着最好在正确的 SHA1(由第一个 product 存储库中的 gitlink 记录的那个)单独(甚至裸露)克隆 config 存储库), 以及 git show BRANCH1:config.json 在另一个克隆的 repo ( with git -C) 中执行。

关于git - git 是否允许 "bare"子模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25537863/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com