
阅读本文大约需要1.1分钟。
点击👆小卡片,回复 “合集” 获取系统性的学习笔记和测试开发技能图谱
问题
在 Jenkins 上通过流水线尝试拉取代码的时候,Git 返回如下错误:
current Git branch is HEAD detached at 0ff123e
当 Jenkins 的 Git 插件 clone 一个 repo 的时候,它会 check out 出一个特定的commit,而不是 repo 的 HEAD,这会导致 repo 处于“detached”状态,因此如果你想对 repo 执行进一步的 git 操作,就需要在 shell 脚本中执行下面的命令来指定分支名:
git checkout ${BRANCH_NAME}
参考:
git checkout--detachRather than checking out a branch to work on it, check out a commit for inspection and discardable experiments. This is the default behavior of "git checkout <commit>" when <commit> is not a branch name. See the "DETACHED HEAD" section below for details.
推荐阅读:
想要明白些道理,遇见些有趣的事 —— 离岛

文章转载自岛哥手记,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




