用释放标记git子模块

时间:2015-08-12 10:11:00

标签: git git-submodules

我们有一个项目,我们使用了很多子模块。在分支和标记我们的版本时,我希望确保使用分支和标记保留子模块状态。因此,如果我们需要再次构建版本,我们可以确保子模块与我们最初使用的版本相同。这样做的最佳方式是什么?

由于

3 个答案:

答案 0 :(得分:1)

不需要您要查找的内容,因为您的子模块的特定版本已链接到您的提交。 因为更新子模块是您在主存储库中提交的内容。

不确定非常明确:-(但它已经通过子模块的工作方式完成了......

答案 1 :(得分:1)

子模块作为 gitlink a special entry in the index)记录在父仓库中。

这意味着标记或分支时子模块状态不会改变:gitlink仍然相同,子模块会检出相同的SHA1。

在父库中创建分支与在子模块中创建分支没​​有任何关系或关系。标签也一样。

答案 2 :(得分:0)

我知道这是一个老问题,但是在这里没有直接答案。

我仅标记超级项目存储库。假设您的工作分支是超级项目及其所有子模块的master

C:\SuperProject>git --version
git version 2.23.0.windows.1

C:\SuperProject>git status
On branch master
Your branch is up to date with 'origin/master'.

C:\SuperProject>git tag v7.3

进行了一些更改并想要返回到v7.3标签之后:

C:\SuperProject>git checkout v7.3
Note: switching to 'v7.3'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 3965477 =
M       submodule

C:\SuperProject>git submodule update --init --recursive
Submodule path 'submodule': checked out 'd9aedca7de2b9fcd873a7823c492ae32bd4b28b7'

C:\SuperProject>cd submodule

C:\SuperProject\submodule>git status
HEAD detached at d9aedca
nothing to commit, working tree clean

要回到主要用途:

cd C:\SuperProject
git checkout master
git submodule foreach --recursive git checkout master

或者,如果您具有here所述的链接分支,则有一个快捷方式:

git checkout master --recurse-submodules