Note: OP milkplus comment refers to the recent Hudson Error 6856 (June 2010), which states:
Git builds with the head disconnected no matter what
It is not yet clear whether this particular problem will be solved (the answers suggest that it can "work as designed"!), It also applies to this version of the hudson Git Plugin , which allows checking the local branch.
You are in DETACHED HEAD because, because the Git plugin is working right now, it made the checkout directly commit SHA1, not the HEAD branch.
The state you are in while your HEAD disconnected is not recorded by any branch (which is natural - you are not in any branch). This means that you can undo your temporary commits and merges by switching to an existing branch.
Your building script may first try to find which branch the corresponding commit comes from .
Since OP milkplus is implemented by looking at the source code of the Hudson Git Plugin :
public void buildEnvVars(AbstractBuild build, java.util.Map<String, String> env) { super.buildEnvVars(build, env); String branch = getSingleBranch(build); if(branch != null){ env.put(GIT_BRANCH, branch); } }
The GIT_BRANCH environment variable is GIT_BRANCH , but it has no value in the xml script structure:
<property environment="env"/> <echo>GIT_BRANCH = ${env.GIT_BRANCH}</echo>
If so, this could be due to issue 7554 :
GIT_BRANCH not set when to build
multiple branches selected.When I tried to determine in which branch the current assembly is enabled, I found that the GIT_BRANCH environment GIT_BRANCH not set when more than one branch was highlighted.
Actually this is not a mistake, as a function, I think - GIT_BRANCH env var is set only if there is one branch, so it does not matter if / when there are several branches. I'm not sure how we will format env var for multiple branches in this context.
I thought that GIT_BRANCH should be set by the branch that is currently being built. For example, if the assembly is on the main, it will contain a wizard.
This will help, for example, to click on another remote that was created during this assembly. Or Run another assembly with the correct set of branches to be created.
View of the NPE mirror described here

For some reason, the Git plugin started passing null for the GIT_BRANCH environment GIT_BRANCH .
This caused the Maven plugin to fail in a call to System.getProperties().putAll(systemProps) .
The solution was to use " master " as the default Git branch, rather than " ** " or an empty string.