2 ms·
>> It's very easy to find yourself on no branch at all > Interesting. In what situation would that happen? I always thought you had to be on some sort of branch
by eru 16y ago
>> It's very easy to find yourself on no branch at all
> Interesting. In what situation would that happen? I always thought you had to be on some sort of branch (master) at least to use git.
If you check out a revision, and not a branch, you will be on "no branch at all". But you asked for it, then.
- jrockway 16y agoAnd of course, you can still commit there and give it a name later. Hack, then cleanup. That's the git model.
- eru 16y agoJust don't do a GC, while you have dangling commits.
- jrockway 16y agoYou're fine as long as the detached head is newer than two weeks old. (And you might be fine past that point. While the branch is "unnamed" it does have a ref in the reflog pointing at it.)
- IdahoEv 16y agoI figured this out eventually. However, when I first switched to git (and before I had tools to show my branch in my prompt), I managed more than once to make 3-4 commits on a detached head, and finding out how to fix that between the documentation and/or Google was essentially impossible. Once I simply gave up and re-did the work. The other time I figured out how to fix it, at the cost of about 3 hours of research and (eventually) questions on the IRC channel. It's a powerful tool, and the docs are fine if you are an expert who already knows what you're looking for. I'll submit that it can be incredibly hard for a noob to learn to use correctly.