Jenkins Git plugin detached HEAD Jenkins Git plugin detached HEAD jenkins jenkins

Jenkins Git plugin detached HEAD


The Checkout/merge to local branch (optional) field is gone in the current (2.2.1) version of the Git plugin.

It has moved to Additional BehavioursCheck out to specific local branch:

Jenkins screenshot of setting option "Check out to specific local branch"

Setting that value to master got me a checked out branch instead of a detached head.


None of the other answer's Jenkins configurations worked for me without having to create manual steps. What indeed works is plain simple:

Repository URL: <repo>Branches to build: masterCheckout/merge to local branch (optional): master


UPDATE (November 2015): Please, note that this solution was given for a specific version of Git plugin (1.1.26). In later versions, the plugin was updated to make configuration easier.

For Jenkins Git plugin version 1.1.26 try this:

Go to Job Configuration. Scroll down to Git section and click "Advanced..." button under "Repositories". Then set:

Name: originRefspec: +refs/heads/branch-0.1:refs/remotes/origin/localbranchname

Then click another "Advanced..." button and set:

Checkout/merge to local branch (optional): localbranchname

You can name the local branch as you like, but the destination in Refspec must match the local branch name in that optional field (in this case "localbranchname"). This will attach HEAD to localbranchname like this:

HEAD -> refs/heads/localbranchname -> 7a698457751bdc043cfda631b81e3812c5361790

Maven Release should pass now in Jenkins.

By the way, this works for me with Jenkins 1.492 and Jenkins Git plugin version 1.1.26.