Subject: could not detach HEAD error didn't identify the cause of the issue

From: Ben Bradshaw <[email-masked]>
Date: Mon, 14 Sep 2009 12:14:24 +1200

Hi,

I was asked to post this issue to the list, I've just had git tell me it
can't detach HEAD which left me scratching mine as to the cause and fix.
Turns out if I have local untracked files that the remote branch also
has then this error will trigger. I have included my shell backlog
(client data removed). In this example the site_map folder was present
on master and I had a local, untracked copy.

git can obviosly detect this issue and stop my local copy getting in a
bad state, but an error message such as "sites/all/modules/site_map/ is
present in HEAD but is untracked locally, unable to apply changes" (or
something to point the finger) would be much appreciated.

ben@carbon:redacted/$ git pull --rebase
remote: Counting objects: 91, done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 74 (delta 27), reused 0 (delta 0)
Unpacking objects: 100% (74/74), done.
>From git+ssh://redacted
   fb1a4c9..bf06bbd  master     -> origin/master
First, rewinding head to replay your work on top of it...
Fast-forwarded master to bf06bbd9e50a2732164fba9e60e65606ab1267ab.
ben@carbon:redacted/$ pwd
/home/ben/redacted
ben@carbon:redacted/$ git pull --rebase
First, rewinding head to replay your work on top of it...
could not detach HEAD
ben@carbon:redacted/$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    sites/all/modules/jquery.ui-1.6.zip
#    sites/all/modules/jquery_ui-6.x-1.3.tar.gz
#    sites/all/modules/jquery_ui/
#    sites/all/modules/modalframe-6.x-1.3.tar.gz
#    sites/all/modules/modalframe/
#    sites/all/modules/nodereference_explorer-6.x-1.1-beta6.tar.gz
#    sites/all/modules/nodereference_explorer/
#    sites/all/modules/noderelationships-6.x-1.1.tar.gz
#    sites/all/modules/noderelationships/
#    sites/all/modules/site_map-6.x-1.1.tar.gz
#    sites/all/modules/site_map/
nothing added to commit but untracked files present (use "git add" to track)
ben@carbon:redacted/$ rm -rf sites/all/modules/site_map/
ben@carbon:redacted/$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    sites/all/modules/jquery.ui-1.6.zip
#    sites/all/modules/jquery_ui-6.x-1.3.tar.gz
#    sites/all/modules/jquery_ui/
#    sites/all/modules/modalframe-6.x-1.3.tar.gz
#    sites/all/modules/modalframe/
#    sites/all/modules/nodereference_explorer-6.x-1.1-beta6.tar.gz
#    sites/all/modules/nodereference_explorer/
#    sites/all/modules/noderelationships-6.x-1.1.tar.gz
#    sites/all/modules/noderelationships/
#    sites/all/modules/site_map-6.x-1.1.tar.gz
nothing added to commit but untracked files present (use "git add" to track)
ben@carbon:redacted/$ git pull --rebase
First, rewinding head to replay your work on top of it...
Fast-forwarded master to 527afccc7565929baf7890b42b1a34174014fee7.

Thanks for your time (and git)
Ben