Hacker News new | ask | show | jobs
by cmehdy 2092 days ago
Thanks for the resource!

I've noticed that if I run a clone `git clone https://gitexercises.fracz.com/git/exercises.git` it gets cloned in "DETACHED HEAD" mode and I need to checkout master, i.e. `git clone https://gitexercises.fracz.com/git/exercises.git -b master`.

Any idea why that is? (It ultimately wasn't a problem once I switched to master, but without doing so there would be no configure.sh script either and I'm asking in case someone else runs into the same issue).

2 comments

It looks like `.git/refs/remotes/origin/HEAD` doesn't exist, which might explain why a fresh clone results in a detached HEAD (i.e. Git should default to being on the branch referenced by this entry).

As for how you can end up in such a state on the remote, I'd actually be interested to know too.

It's a part of the exercise.
Is it, though? If the instructions in your "How to start?" section don't work, that feels more like a bug. I went through all the exercises and didn't find a point where this was relevant.

Currently, the initial HEAD actually contains the solution for a future exercise. It was also created by a different user than the rest of the exercises.

Maybe the detached HEAD should contain a README with instructions like "You are in detached HEAD mode, reach the master branch to continue"