自动化 Qt 构建 - 子模块问题。无法获得干净的工作目录
Automating Qt build - Submodule issue. Can not get a clean working directory
我想为特定的 Qt 版本自动化构建过程。根据 Qt wiki 的命令是
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
当执行这个命令时,有消息说一些目录被跳过了——但没有说明原因。因此工作目录仍然包含未跟踪的内容。
有人知道哪些神奇的命令可以真正获得干净的工作目录吗?
如果您仔细阅读 git clean
的联机帮助页,您会看到它指出:
Git will refuse to delete directories with .git sub directory or file unless a second -f is given.
因此,要真正获得干净的目录树,您必须像这样进行清理
git submodule foreach --recursive "git clean -dffx" && git clean -dffx
这将完全删除存储库。因此,如果您切换到另一个包含子模块的版本 - 它必须再次克隆。
我想为特定的 Qt 版本自动化构建过程。根据 Qt wiki 的命令是
git clone https://code.qt.io/qt/qt5.git
git checkout v5.9.0
git submodule update --init --recursive
这行得通,结果是一个干净的工作目录,其中已签出版本 5.9.0。现在我使用命令
检查了版本 5.8.0git 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
当执行这个命令时,有消息说一些目录被跳过了——但没有说明原因。因此工作目录仍然包含未跟踪的内容。
有人知道哪些神奇的命令可以真正获得干净的工作目录吗?
如果您仔细阅读 git clean
的联机帮助页,您会看到它指出:
Git will refuse to delete directories with .git sub directory or file unless a second -f is given.
因此,要真正获得干净的目录树,您必须像这样进行清理
git submodule foreach --recursive "git clean -dffx" && git clean -dffx
这将完全删除存储库。因此,如果您切换到另一个包含子模块的版本 - 它必须再次克隆。