I ran across a really funny issue the other day. I was working with GIT commands and trying to get my branch cleaned up and in sync. In the process of cleaning my GIT repo I came across a HEAD command when running the GIT STATUS command. In essence the response was showing the HEAD was not being tracked when I ran the GIT STATUS command. The message: nothing added to commit but untracked files present (use “git add” to track) was present. Let me show you.
By contrast a clean GIT STATUS command should responde with a message such as “nothing to commit (working directory clean)”
This seemed incredibly odd to me. how did the Branch HEAD get in an untracked state? That seemed as if my branch was completely broken and I worried that I would have to remove it and do a fresh checkout.
Instead I decided to poke around the file system and see if anything was out of place there. When i did so i found the following file:
Then it suddenly dawned on me. GIT was trying to tell me that I had a file named “HEAD” at the root of my git repo that was in an untracked state. That HEAD file was completely empty. Just a blank file. It must have erroneously been created in the midst of my various GIT commands.
I validated that the file was in deed empty – then I removed it from the filesystem. The warning from GIT saying that it was untracked went away and my branch was 100% clean again.