3 ms·
Git does make a detached head sound like something is broken, but it's really just a nameless branch. Nothing broken about it. Any commits might become hidden,
by Buttons840 3y ago
Git does make a detached head sound like something is broken, but it's really just a nameless branch. Nothing broken about it. Any commits might become hidden, as all commits not in a branch are, but that's only after you move off the headless branch and git warns loudly about this.
- ziml77 3y agoI just tested to see what happens if you don't name a branch before leaving it. Surprisingly, despite all that scary looking text about detached head, if you switch over to another branch git will print out a message that you're leaving commits on an unnamed branch as well as instructions on how to get back and name it later (and of course the commit hash can also be recovered from the reflog). So yeah not only is the detached head state not a broken state, it's not even really a scary state to be in.
- _ikke_ 3y agoFor someone who understands git, it certainly is not. But if you are not aware of how git works, committing things when HEAD is detached could to confusion in the best case, and lost commits in the worst.