public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Nicolas Sebrecht <nicolas.s.dev@gmx•fr>
Cc: Matthieu Moy <Matthieu.Moy@imag•fr>, git@vger•kernel.org
Subject: Re: [PATCH] Re: push: point to 'git pull' and 'git push --force' in case of non-fast forward
Date: Thu, 06 Aug 2009 14:32:13 -0700	[thread overview]
Message-ID: <7vprb8d3xe.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20090806211610.GB12924@vidovic> (Nicolas Sebrecht's message of "Thu\, 6 Aug 2009 23\:16\:10 +0200")

Nicolas Sebrecht <nicolas.s.dev@gmx•fr> writes:

>> +Note about fast-forwards
>> +------------------------
>> +
>> +When an update changes a branch (or more in general, a ref) that used to
>> +point at commit A to point at another commit B, it is called a
>> +fast-forward update if and only if B is a descendant of A.
>> +
>> +In a fast-forward update from A to B, the set of commits that the original
>> +commit A built on top of is a subset of the commits the new commit B
>> +builds on top of.  Hence, it does not lose any history.
>> +
>> +In contrast, a non-fast-forward update will lose history.
>
> I believe that this sentence a bit too much scaring for the beginner.
> There are two kinds of update (push and pull). We loose history only
> when pushing.

Three points that makes me think your suggested update is not appropriate
are:

 (1) This patch is about git-push documentation;

 (2) The opposite of git-push is git-fetch, not git-pull; and a non
     fast-forward fetch does lose history if you start building on a
     now-rewound tip of the remote tracking branch; and

 (3) We _do_ want this section to be scary.  We want the readers to be
     fully aware of the implications before tempting them with the --force
     option.

>> +Alternatively, you can rebase your change between X and B on top of A,
>> +with "git pull --rebase", and push the result back.  The rebase will
>> +create a new commit D that builds the change between X and B on top of
>> +A.
>> +
>> +----------------
>> +
>> +      B   D
>> +     /   /
>> + ---X---A
>> +
>> +----------------
>
> Wouldn't "git pull --rebase" loose B? Shouldn't we have this
>
>   ----------------
>   
>             D
>            /
>    ---X---A
>   
>   ----------------
>
> instead?

This makes B _loose_ (or, dangling), but does not _lose_ it.  It is still
reachable from the reflog.

We could choose to not draw it for simplicity, or we could annotate it
like this for completeness (and to give a warm-fuzzy feeling to the reader
that nothing is lost).

----------------

       branch@{1} (reachable from reflog)
             branch
      B      D
     /      /
 ---X------A

----------------

I don't know which is better.  If we were printing in colours in the
documentation, I would keep B but draw it in light gray.

  reply	other threads:[~2009-08-06 21:32 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-06 17:32 [PATCH] push: point to 'git pull' and 'git push --force' in case of non-fast forward Matthieu Moy
2009-08-06 20:04 ` Michael J Gruber
2009-08-07 19:21   ` Matthieu Moy
2009-08-07 19:46     ` Michael J Gruber
2009-08-06 20:15 ` Junio C Hamano
2009-08-06 21:16   ` [PATCH] " Nicolas Sebrecht
2009-08-06 21:32     ` Junio C Hamano [this message]
2009-08-07 19:37   ` [PATCH] " Matthieu Moy
2009-08-07 20:05     ` Junio C Hamano
2009-08-07 20:22       ` Matthieu Moy
2009-08-08  7:51 ` [PATCH v2] " Matthieu Moy
2009-08-08  8:35   ` Teemu Likonen
2009-08-08 15:22     ` Matthieu Moy
2009-08-08 16:25       ` Junio C Hamano
2009-08-08 22:23         ` [PATCH v2] " Nicolas Sebrecht
2009-08-09 18:35         ` [PATCH v2] " Matthieu Moy
2009-08-09 20:22           ` Junio C Hamano
2009-08-10  8:43             ` Matthieu Moy
2009-08-10  8:49               ` Junio C Hamano
2009-08-10  8:56                 ` Matthieu Moy
2009-08-11  3:03         ` Nanako Shiraishi
2009-09-06  6:44           ` [RFC/PATCH 0/4] make helpful messages optional Jeff King
2009-09-06  6:46             ` [PATCH 1/4] push: fix english in non-fast-forward message Jeff King
2009-09-06  6:47             ` [PATCH 2/4] push: re-flow " Jeff King
2009-09-06  6:48             ` [PATCH 3/4] push: make non-fast-forward help message configurable Jeff King
2009-09-06  7:09               ` Junio C Hamano
2009-09-06  7:23                 ` Jeff King
2009-09-06  7:30                   ` Junio C Hamano
2009-09-06  7:32                     ` Jeff King
2009-09-06  7:52                   ` Junio C Hamano
2009-09-06 11:30                     ` Sverre Rabbelier
2009-09-07  0:44                     ` Nanako Shiraishi
2009-09-07  7:35                       ` Johannes Sixt
2009-09-07  7:40                       ` Mike Hommey
2009-09-07  8:24                       ` Jeff King
2009-09-07  8:34                         ` Matthieu Moy
2009-09-07  8:54                           ` Jeff King
2009-09-07 11:20                             ` Matthieu Moy
2009-09-08 18:51                             ` Uri Okrent
2009-09-09 11:22                               ` Jeff King
2009-09-09 11:26                   ` [PATCH 0/2] configurable advice messages Jeff King
2009-09-09 11:38                     ` [PATCH 1/2] push: make non-fast-forward help message configurable Jeff King
2009-09-09 19:06                       ` Junio C Hamano
2009-09-09 20:39                         ` Jeff King
2009-09-09 21:47                           ` Junio C Hamano
2009-09-09 11:43                     ` [PATCH 2/2] status: make "how to stage" messages optional Jeff King
2009-09-06  6:50             ` [PATCH 4/4] " Jeff King
2009-09-06 11:53             ` [RFC/PATCH 0/4] make helpful " Matthieu Moy

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

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

  git send-email \
    --in-reply-to=7vprb8d3xe.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox$(echo .)com \
    --cc=Matthieu.Moy@imag$(echo .)fr \
    --cc=git@vger$(echo .)kernel.org \
    --cc=nicolas.s.dev@gmx$(echo .)fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox