> $ git branch recentwork 9c51d95 > > And I will have a branch at that point?
> Sorry, make that: > > $ git branch recentwork 8658a39 I can honestly never remember what order the branch name and hash go in so I tend to usually use the more longwinded approach. $ git checkout 8658a39 $ git checkout -b recentwork I'm sure it would fail gracefully if you got the order wrong (you probably have it right, I'm just saying), but I just tend to remember this way easier. It is more intuitive to use the branch command to create a branch I would argue though, so maybe you should not learn from my example. :-) > I see. Well, it would be nice if it gave a little warning. I think I > understand why it happened now though. I was tagging some old versions > that I had failed to do in the past. Not exactly sure how but that > must have been why. Yeah, agreed. It's not always immediately obvious. It'll say "Not currently on any branch." in the git commit message boilerplate as well as git status output though, so I try to keep my eyes peeled for that not being the branch I think I'm on. I like to turn on auto coloring in git config and then it colors that red so I notice it. I don't remember the config variable offhand but you should be able to look it up on the git config man page. Not sure why it's not the default setting. I suppose people don't like tools messing with their terminal colors by default? Also with the shell prompt bit from before, you'll notice that your branch is a hash instead of an actual branch name. dan On Tue, Jun 1, 2010 at 2:05 PM, Trans <[email protected]> wrote: > > > On Jun 1, 4:39 pm, Dan Preston <[email protected]> wrote: >> You should be ok. You can use the "git reflog" command to view the >> history of what you've had checked out. You can then checkout the >> hash commit of your latest work again and create a branch from it. Or >> alternatively you can merge that hash back to master. > > Thank the maker! So the commits are still in there. My reflog reads: > > 9c51d95... h...@{0}: checkout: moving from master to master > 9c51d95... h...@{1}: checkout: moving from html-based to master > 8f1c474... h...@{2}: checkout: moving from master to html-based > 9c51d95... h...@{3}: checkout: moving from > 8658a3910e3ca3b5e66fce6503b42fa431369430 to master > 8658a39... h...@{4}: commit: added multi-pattern matches and evaluator > no longer uses traverse > bb34a07... h...@{5}: commit: admin: add REQUIRE file > 425d22f... h...@{6}: commit: test: add helpers qed test > 958447f... h...@{7}: commit: admin: add roadmap and fix version file > ... > > so I can do: > > $ git branch recentwork 9c51d95 > > And I will have a branch at that point? > >> The (no branch) thing happens when you checkout a hash somewhere in >> your history that isn't associated with any tag or HEAD of a branch. >> If you then begin committing from there, you end up in the situation >> you are in now. It's easy to rectify, but sometimes hard to notice. > > I see. Well, it would be nice if it gave a little warning. I think I > understand why it happened now though. I was tagging some old versions > that I had failed to do in the past. Not exactly sure how but that > must have been why. > >> I insert this into my bash .profile so that the current branch is >> displayed in my terminal prompt. You may find it useful. >> >> # Show the git branch in the prompt >> PS1='[...@\h \W$(__git_ps1 " (%s)")]\$ ' > > I like it. I will use. Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Git for human beings" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/git-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/git-users?hl=en.
