在 Azure DevOps 上构建管道时 Detached Head

Detached Head while building pipeline on Azure DevOps

我在 git 分支的管道构建阶段注意到以下内容。但是,当我在我的开发环境中签出分支时,我没有收到 'HEAD DETACHED' 错误。这个错误是重要的还是只是 Azure DevOps 上所有基于 git 的管道构建的预期结果?

Note: switching to 'd1be2f5491ae7fbb40fc7ec095c4be44b4120dc5'.

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

Or undo this operation with:

git switch -

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

HEAD is now at d1be2f5 Update azure-pipelines.yml for Azure Pipelines

这不是错误,这就是为什么它没有被报告为错误,没有出现可怕的红色文本,也没有停止构建。

这是预期的行为。

这是一种预期行为,一种临时 Git 状态。对于我们的项目,它破坏了我们以二进制形式保存的构建信息,我们丢失了分支信息。使用

启动构建管道
git checkout <branch>
git pull

修复了这个问题。不知道为什么 pull 是必要的,否则它在 HEAD 后面有 1 个提交。