Git 不能';找不到远程参考头(与Jenkins和Maven一起释放工件时)

Git 不能';找不到远程参考头(与Jenkins和Maven一起释放工件时),git,jenkins,maven-release-plugin,Git,Jenkins,Maven Release Plugin,我目前正试图使用maven发布插件在jenkins的一个Git项目中工作 如下图所示,我的远程存储库(服务器上)中似乎缺少对HEAD的引用。此引用仅在主分支名已更改为其他名称的项目中丢失 10:12 $ git ls-remote https://git.mycompany.com/mycompany/common.git cb6fd9d62d963e9d20499e7dcfcfc8742e799333 refs/heads/development 5fd387bcbaf56312a108

我目前正试图使用
maven发布插件
在jenkins的一个Git项目中工作

如下图所示,我的远程存储库(服务器上)中似乎缺少对HEAD的引用。此引用仅在主分支名已更改为其他名称的项目中丢失

10:12 $ git ls-remote https://git.mycompany.com/mycompany/common.git
cb6fd9d62d963e9d20499e7dcfcfc8742e799333    refs/heads/development
5fd387bcbaf56312a108b1e07236a25a325f1a79    refs/heads/production
d5d97e7ce2c634ce5ab8cb7d68a2cf9c67ece2ea    refs/tags/1.0.0
1317bcd74008313f0a9933d840fbcd4356ed51c7    refs/tags/1.0.0^{}
有没有一种方法可以从GitLab或使用Git远程创建这种引用

以下是maven发布插件的执行日志:

[INFO] --- maven-release-plugin:2.5.1:perform (default-cli) @ common ---
[INFO] Checking out the project to perform the release ...
[INFO] Executing: /bin/sh -c cd /var/lib/jenkins/jobs/common/workspace/common/target && git clone --branch 1.0.1 https://git.mycompany.com/mycompany/common.git /var/lib/jenkins/jobs/common/workspace/common/target/checkout
[INFO] Working directory: /var/lib/jenkins/jobs/common/workspace/common/target
[INFO] Executing: /bin/sh -c cd /tmp && git ls-remote https://git.mycompany.com/mycompany/common.git
[INFO] Working directory: /tmp
[INFO] Executing: /bin/sh -c cd /var/lib/jenkins/jobs/common/workspace/common/target/checkout && git fetch https://git.mycompany.com/mycompany/common.git
[INFO] Working directory: /var/lib/jenkins/jobs/common/workspace/common/target/checkout
[ERROR] The git-pull command failed.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] common ............................................. FAILURE [ 32.825 s]
[INFO] common :: common-validation ........................ SKIPPED
[INFO] common :: common-sessions .......................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 33.960 s
[INFO] Finished at: 2015-02-03T10:39:04+01:00
[INFO] Final Memory: 20M/395M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:perform (default-cli) on project common: Unable to checkout from SCM
[ERROR] Provider message:
[ERROR] The git-pull command failed.
[ERROR] Command output:
[ERROR] Cloning into '/var/lib/jenkins/jobs/common/workspace/common/target/checkout'...
[ERROR] Note: checking out '78ec6e9c81d25890de75ce671d809bf5d3949ed8'.
[ERROR] 
[ERROR] You are in 'detached HEAD' state. You can look around, make experimental
[ERROR] changes and commit them, and you can discard any commits you make in this
[ERROR] state without impacting any branches by performing another checkout.
[ERROR] 
[ERROR] If you want to create a new branch to retain commits you create, you may
[ERROR] do so (now or later) by using -b with the checkout command again. Example:
[ERROR] 
[ERROR] git checkout -b new_branch_name
[ERROR] 
[ERROR] fatal: Couldn't find remote ref HEAD
[ERROR] Unexpected end of command stream
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:

显然这是一个与GitLab相关的问题

已设置默认分支,但在(在项目设置中)将另一个分支设置为默认分支后,会出现标头引用:

cb6fd9d62d963e9d20499e7dcfcfc8742e799333    HEAD
cb6fd9d62d963e9d20499e7dcfcfc8742e799333    refs/heads/development
07bef68adb8d10956bdba81d07887f793feab76b    refs/heads/production
d5d97e7ce2c634ce5ab8cb7d68a2cf9c67ece2ea    refs/tags/1.0.0
1317bcd74008313f0a9933d840fbcd4356ed51c7    refs/tags/1.0.0^{}
我把它切换回默认的分支,头仍然在那里


发布过程是成功的

当我的存储库还没有创建
master
分支时,我遇到了相同的错误

$git branch master
解决了我的问题。

无论如何,总有一个HEAD引用(这是存储库成为存储库的要求)。当
HEAD
是对未出生分支的间接引用时会发生这种情况,当您使用
git init
创建空存储库时会发生这种情况,如果您从未创建
master
,则会持续发生这种情况。GitLab是否(如果是的话,如何)允许您重新指向间接引用,我不知道。