Re: [PATCH] tone down the detached head warning
- From
Junio C Hamano <junkio@cox.net>
- Date
- Feb 1, 2007, 03:23 UTC
- Message-ID
- <7vd54ur26u.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <20070201030030.GA1979@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I think part of the "scariness" of the message is that git-checkout does > not _usually_ produce output. I wonder if, when switching HEAD, it > usually printed "Now on branch <foo>", and for detached printed some > special variant, it would seem more natural.
That sounds sensible. Another thing I found slightly annoying about branch switching in git-checkout is that we list the paths with local changes only when the tip of the old branch and the new branch are different. Very often I start hacking while on 'master' and later find the change forms a concrete "theme", and then say "git checkout -b that-theme" to switch a branch; in such a case I do want the list of locally modified paths.
For example:
: gitster project/master; edit foo.c
: gitster project/master; git checkout -b theme
M foo.c
Switched to a new branch "theme"
: gitster project/theme; edit bar.c
: gitster project/theme; git checkout master
M bar.c
M foo.c
Switched to branch "master"
: gitster project/master; git checkout master^
M bar.c
M foo.c
Detached your HEAD -- you are not on any branch.
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
: gitster project; would feel very natural and much less scary.
Note. I run with PS1=': \h \W$(__git_ps1 "/%s"); '.