"Git fatal: ref HEAD is not a symbolic ref" while using maven release plugin

I ran into the same error on Jenkins in combination with maven release plugin, we fixed it by going to Additional behaviours, Check out to specific local branch and enter 'master'

I realise this is not a solution but it might give you some direction in where to look.


The problem in Atlassian Bamboo was solved by un-checking the default setting Use shallow clones with description Fetches the shallowest commit history possible. Do not use if your build depends on full repository history. This checkbox is located under Plan Configuration -> Repositories tab -> Git -> Advanced options

After this all the releases work fine.


For Jenkins and GIT add the additional behaviour check out to specific local branch and use the Workspace Cleanup Plugin to clean your workspace to the beginning of your CI job.


Unchecking the Use shallow clones was not sufficient in my case (I'm using Bamboo 5.7.2). I needed to also enable Force Clean Build in the Source Code Checkout task. Enabling the Use shallow clones would work for the next execution of the job, but all subsequent execution would result in the same error.