' HEAD在'当jenkins跑

时间:2017-01-04 13:37:57

标签: git github jenkins

我有一个jenkins工作,其配置如图所示,

SCM Configuration

Build Trigger

我的jenkins工作区是我的本地repo目录,如下所示 D:\Jenkins\workspace\FirstProject\TestCI

即TestCI是我的github repo名称,我克隆在上面的位置并将其设置为我的jenkins工作空间路径。

所以基本上我的jenkins工作会在将更改推送到我的github仓库时构建,并且在构建之后我在我的本地仓库中输入git status时会得到错误' HEAD在'

分离

当jenkins工作建立时,我的头被分离的原因是什么?

1 个答案:

答案 0 :(得分:3)

我怀疑Jenkins使用它的提交ID签出了一个特定的提交。 HEAD通常指向分支,指向提交。 例如

 cat HEAD
ref: refs/heads/master

如果你使用它的SHA签出完全相同的提交,那么当HEAD包含SHA并且你处于分离的HEAD状态时。

git checkout bfe387b5fdcccdfb9d318b24589ab8f0eca9ab6a
Note: checking out 'bfe387b5fdcccdfb9d318b24589ab8f0eca9ab6a'.

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 performing another checkout.

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

  git checkout -b new_branch_name

HEAD is now at bfe387b... initial

现在,如果我们查看HEAD,我们会看到它包含提交ID。

cat .git/HEAD
bfe387b5fdcccdfb9d318b24589ab8f0eca9ab6a