git 子模块 - 如何撤消 git 子模块更新 --init

问题描述 投票:0回答:1

我有一个 git 项目,其中包含几个子模块。 从现在到一年前,几个子模块已经移动 - 甚至其中一些相同的子模块也已向下移动了一个目录级别。另一个 URL 从一个 URL 移动到另一个 URL 位置。 Git 不会善意地接受这样的改变:)

当我有了 git 并运行了

git submodule update --init
- 那么我就无法运行了

$ git checkout OLDSHA
fatal: not a git repository: sub/depdir/../../.git/modules/sub/depdir

或者我得到

fatal: could not get a repository handle for submodule 'sub/depdir'

如果我从头开始克隆 git,请运行

git checkout OLDSHA
- 然后运行
git submodule update --init
,没有问题。

那么我的问题:

  • 有没有办法撤消
    git submodule update --init
    ,这基本上让我回到了
    git clone PROJECT && cd project && git checkout OLDSHA
  • 之后得到的结果

注意;这并不是要删除我的子模块。问题是使我的例如更有效地运行 git bisect 来处理这些更改,而无需从头开始重新克隆。

git git-submodules
1个回答
0
投票

使用较新的 git 我现在可以运行

git submodule deinit sub/depdir

然后

git checkout some_old_sha 

就像魅力一样

© www.soinside.com 2019 - 2024. All rights reserved.