git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Daniel Barkalow <barkalow@iabervon.org>,
	Johannes Sixt <j.sixt@viscovery.net>,
	Thomas Rast <trast@student.ethz.ch>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Euguess@gmail.com, Mikael Magnusson <mikachu@gmail.com>,
	Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Jay Soffian <jaysoffian@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so
Date: Tue, 13 Oct 2009 15:46:41 -0700	[thread overview]
Message-ID: <7vhbu2syi6.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20091013215751.GA12603@coredump.intra.peff.net> (Jeff King's message of "Tue\, 13 Oct 2009 17\:57\:52 -0400")

Jeff King <peff@peff.net> writes:

> On Tue, Oct 13, 2009 at 05:31:46PM -0400, Daniel Barkalow wrote:
>
>> I personally think that the real issue is that our "detached HEAD" message 
>> is still too scary, and what we really want is to issue the scary message 
>> when using "git commit" to move a detached HEAD from what was checked out 
>> to a new commit. So:
>
> This has been discussed before (I happen to agree with you, but you
> probably want to address other comments in the thread):
>
>   http://thread.gmane.org/gmane.comp.version-control.git/38201/focus=38213

I just re-read the discussion again (thanks for a useful pointers).  I
mostly agree with everything said in the thread and obviously agree with
its conclusion, but one thing I noticed that everybody (who _was_ a git
expert) in the thread was assuming bothered me somewhat.

In this sequence:

    1$ git checkout $commit_name_that_is_not_a_local_branch
    2$ git commit; hack; hack; hack;...
    3$ git checkout $branch_name

Step #1 is where the HEAD is detached.  It is correct to argue that
detached HEAD is a different state and we should inform unsuspecting
users, which we do.

Step #2 is where a commit that is not connected to any ref is made.

Step #3 is where the state built in the detached HEAD "branch" vanishes
into lost-found.

The experts argued that #3 is where it is dangerous, and while it is
technically correct, an unsuspecting non-expert would not even _know_ that
nothing dangerous is happening while in step #2.

If the commit name used in step #1 were "v1.0.0", and if the user while in
step #2 ran "gitk v1.0.0" (or "git log v1.0.0"), he will be confused by
not seeing the recent commits.  The distinction between "detached HEAD"
and being on a branch needs to be understood to appreciate this (and taken
advantage of, when running e.g. "git show-branch v1.0.0 HEAD").

Way before step #3, such a user, even though technically not in any danger
yet, would be confused and panic: "I wanted to fix something in the 1.0.0
release, but where did my fix go?"

The current message in step #1 reads like this:

    $ git checkout origin/next
    Note: moving to 'origin/next' which isn't a local 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>
    HEAD is now at 9ecb2a7... Merge branch 'maint'

And perhaps for people who do not understand the second point in the
four-point list [*1*] I showed earlier in the thread, "If you want to
create a new branch" may not be descriptive enough, as a sight-seer and an
occasional typofixer, the user does not know what branch is good for to
begin with, and would not be able to tell if s/he even "wants to create"
one.  Perhaps it would help more if we reworded three lines after "Note:"
with something like:

    To keep the history of commits you will build from now on in a branch,
    you may want to do "git checkout -b <new-branch-name>" now.

and customize the "in a branch" and <new-branch-name> part if the checkout
was given a remote tracking branch and the corresponding local branch does
not yet exist, e.g. in the above example:

    To keep the history of commits you will build from now on in 'next'
    branch, you may want to do "git checkout -b next" now.


[Footnote]

*1* The world model in which a git user works is:

 * You clone and get copies of where the other end has its branches;

 * You do all your work on your local branches;

 * You may incorporate what the other end further did by merging from the
   tracking branch from it;

 * You update the other end by pushing what you did on your local branches.

I do not think you can nor should hide them from the user [*2*].

*2* We had to repeat "don't hide but teach" many times until it finally
sank in for another essential thing in the git world model.  I hope we do
not have to do the same repeating for the above four points.  Luckily we
do not have to repeat "don't hide but teach" about the index anymore these
days.

  reply	other threads:[~2009-10-13 22:48 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-05 20:46 [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so Jay Soffian
2009-10-05 21:03 ` Sverre Rabbelier
2009-10-05 21:17 ` Johannes Schindelin
2009-10-05 21:26   ` Sverre Rabbelier
2009-10-05 21:57     ` Jay Soffian
2009-10-05 22:00   ` Jay Soffian
2009-10-05 22:45     ` Johannes Schindelin
2009-10-05 22:56   ` Jeff King
2009-10-06  7:32     ` Thomas Rast
2009-10-06  9:16       ` Johannes Schindelin
2009-10-06 11:36         ` Junio C Hamano
2009-10-06 12:02           ` Johannes Schindelin
2009-10-06 20:09             ` Junio C Hamano
2009-10-06  9:12     ` Johannes Schindelin
2009-10-06  9:28       ` Matthieu Moy
2009-10-06  9:41         ` Mikael Magnusson
2009-10-06 10:04           ` Johannes Schindelin
     [not found]           ` <0016e68fd0123a175304754694b4@google.com>
2009-10-06 16:43             ` Eugene Sajine
2009-10-06 20:33               ` Junio C Hamano
2009-10-12  7:49             ` Johannes Schindelin
2009-10-12 18:36               ` Björn Steinbrink
2009-10-12 21:40               ` Thomas Rast
2009-10-12 22:49                 ` Junio C Hamano
2009-10-13  6:36                   ` Thomas Rast
2009-10-13  7:16                     ` Junio C Hamano
2009-10-13  8:44                       ` Junio C Hamano
2009-10-13  8:51                       ` Thomas Rast
2009-10-13  9:24                         ` Junio C Hamano
2009-10-13 21:20                           ` Johannes Schindelin
2009-10-13 21:59                             ` Junio C Hamano
2009-10-13 22:06                             ` Jeff King
2009-10-13 23:22                               ` Johannes Schindelin
2009-10-14  1:05                                 ` Jay Soffian
2009-10-14  3:28                                   ` Junio C Hamano
2009-10-14 12:49                                     ` Jay Soffian
2009-10-14 19:31                                       ` Junio C Hamano
2009-10-25 17:44                                     ` Uri Okrent
2009-10-14  4:31                                 ` Jeff King
2009-10-14  9:56                         ` Thomas Rast
2009-10-14 10:46                           ` Jakub Narebski
2009-10-13  9:32                       ` Johannes Sixt
2009-10-13 18:39                       ` Daniel Barkalow
2009-10-13 20:53                         ` Junio C Hamano
2009-10-13 21:31                           ` Daniel Barkalow
2009-10-13 21:57                             ` Jeff King
2009-10-13 22:46                               ` Junio C Hamano [this message]
2009-10-13 23:16                                 ` Johannes Schindelin
2009-10-14  9:33                                   ` Thomas Rast
2009-10-16 11:48                                     ` Johannes Schindelin
2009-10-16 12:07                                       ` Thomas Rast
2009-10-25 17:48                                 ` Uri Okrent
2009-10-26  7:14                                   ` Junio C Hamano
2009-10-13 22:38                             ` Björn Steinbrink
2009-10-18  7:58   ` Junio C Hamano
2009-10-18  8:00     ` [PATCH 1/3] check_filename(): make verify_filename() callable without dying Junio C Hamano
2009-10-18  8:01     ` [PATCH 2/3] DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz" Junio C Hamano
2009-10-18 10:34       ` Nanako Shiraishi
2009-10-18 12:00         ` Björn Steinbrink
2009-10-18 20:20           ` Nanako Shiraishi
2009-10-18 22:50             ` Junio C Hamano
2009-10-19  5:58             ` Björn Steinbrink
2009-10-18  8:01     ` [PATCH 3/3] git checkout --nodwim Junio C Hamano
2009-10-18 12:40       ` Alex Riesen
2009-10-18 19:53         ` Junio C Hamano
2009-10-18 21:02           ` [PATCH] Use "--no-" prefix to switch off some of checkout dwimmery Alex Riesen
2009-10-18 22:49             ` Junio C Hamano
2009-10-19  6:07               ` Alex Riesen
2009-10-19  6:12                 ` Alex Riesen
2009-10-19  6:16                   ` Junio C Hamano
2009-10-19  7:17                     ` Alex Riesen
2009-10-19  7:25                       ` Junio C Hamano
2009-10-21 17:29           ` [PATCH 3/3] git checkout --nodwim Avery Pennarun
2009-10-21 21:21             ` Nanako Shiraishi
2009-10-21 22:14               ` Junio C Hamano
2009-10-21 22:35                 ` [PATCH] git checkout --no-guess Junio C Hamano
2009-10-21 22:51                   ` Avery Pennarun
2009-10-26 18:17                     ` Jay Soffian
2009-10-26 18:25                       ` Avery Pennarun
2009-10-22  0:27               ` [PATCH 3/3] git checkout --nodwim Johannes Schindelin
2009-10-22  7:09                 ` Erik Faye-Lund
2009-10-23  8:57                 ` Michael J Gruber
2009-10-24  6:35                 ` Junio C Hamano
2009-10-24 14:59                   ` David Roundy
2009-10-24 19:25                     ` Junio C Hamano
2009-10-26 20:12                     ` Johannes Schindelin
2009-10-26 20:40                       ` Avery Pennarun
2009-10-26 21:26                         ` Jeff King
2009-10-26 22:01                           ` Avery Pennarun
2009-10-26 22:14                             ` Jeff King
2009-10-26 22:28                               ` Avery Pennarun
2009-10-05 22:52 ` [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vhbu2syi6.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Euguess@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=jaysoffian@gmail.com \
    --cc=mikachu@gmail.com \
    --cc=peff@peff.net \
    --cc=trast@student.ethz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).