嵌套的git仓库没有子模块? [英] Nested git repositories without submodules?

查看:201
本文介绍了嵌套的git仓库没有子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎父代仓库中的git仓库不包含在父项的提交中,除非它被设置为子模块。是否有可能重写此行为并将嵌套的git回购视为任何其他目录?我不想通过子模块来依赖外部依赖,但希望使用git来管理项目中的这些依赖。

解决方案

1 /您可以通过以下方式覆盖:


  • 或者 git config 设置:设置环境变量 $ GIT_DIR <
    将嵌套Git工作树的 .git 目录定义为外部 .git (在嵌套仓库和主仓库外部)
  • 或者在主仓库外设置嵌套仓库'N' 但检出repo'N'里面主要的回购:


 core.worktree  pre> 

将路径设置为工作树的根目录。这可以被 GIT_WORK_TREE 环境变量和 - 工作树命令行选项覆盖



在这两种情况下,这个想法都是嵌套工作树,没有任何 .git 子目录。



2 /对于子模块,嵌套的git repo并不真正包含在父回购中。

A 特殊条目 是在父树中记录外部Git SHA1。

 新档案模式160000 
索引0000000..4c4c5a2

另见 Git子模块的性质(第三答案的一部分)

It seems a git repo inside a parent repo isn't included in a commit on the parent unless it's setup as a submodule. Is it possible to override this behaviour and treat the nested git repo as any other directory? I don't want to rely on external dependencies through submodules but want to use git to manage these dependencies within the project.

解决方案

1/ You could override that through:

  • either a git config setting: set the environment variable $GIT_DIR
    you define your .git directory of the nested Git working tree as an external .git (external to both the nested repo and the main repo)
  • or by setting your nested repo 'N' outside the main repo, but checkout that repo 'N' inside the main repo:

core.worktree

Set the path to the root of the work tree. This can be overridden by the GIT_WORK_TREE environment variable and the --work-tree command line option

In both case, the idea is to have a nested worktree without any .git subdirectory in it.

2/ With submodules, the nested git repo is not really included in the parent repo.
A special entry is made in the parent tree to record the external Git SHA1.

new file mode 160000
index 0000000..4c4c5a2

See also "nature of Git submodules" (third part of the answer)

这篇关于嵌套的git仓库没有子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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