自动化Qt构建 - 子模块问题。无法获得干净的工作目录

时间:2018-05-18 08:51:44

标签: git qt git-submodules

我想自动化特定Qt版本的构建过程。根据{{​​3}},这些命令是

git clone https://code.qt.io/qt/qt5.git
git checkout v5.9.0
git submodule update --init --recursive

这很有效,结果是一个干净的工作目录,版本5.9.0签出。现在我用命令

检查了5.8.0版本
git checkout v5.8.0
git submodule update --init --recursive

在更新期间,有一些警告说某些目录无法删除,因为它们不是空的。现在git status的结果看起来像这样

HEAD detached at v5.8.0
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

        modified:   qtdeclarative (untracked content)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        qtremoteobjects/

Qt wiki中,清洁过程被声明为

git submodule foreach --recursive "git clean -dfx" && git clean -dfx

执行此命令时,会显示某些目录被跳过的消息 - 但未说明原因。因此,工作目录仍包含未跟踪的内容。

任何人都知道哪些神奇的命令可以真正获得干净的工作目录?

1 个答案:

答案 0 :(得分:1)

如果您仔细阅读git clean的联机帮助页,您会看到它的声明:

  

Git将拒绝删除带.git子目录或文件的目录,除非给出第二个-f。

因此,要真正获得一个干净的目录树,你必须像这样进行清理

git submodule foreach --recursive "git clean -dffx" && git clean -dffx

这将完全删除存储库。因此,如果您切换到包含子模块的另一个版本 - 必须再次克隆它。