From: Junio C Hamano <gitster@pobox.com>
To: Matthieu Moy <Matthieu.Moy@imag.fr>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] push: point to 'git pull' and 'git push --force' in case of non-fast forward
Date: Fri, 07 Aug 2009 13:05:44 -0700 [thread overview]
Message-ID: <7vd477v17r.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <vpqvdkzwh3j.fsf@bauges.imag.fr> (Matthieu Moy's message of "Fri\, 07 Aug 2009 21\:37\:20 +0200")
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> +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
>> +
>> +----------------
>> +
>> +Again, updating A with this commit will fast-forward and your push will be
>> +accepted.
>
> Maybe add something about --force ? I don't like my wording very much,
> but a first try is this:
>
> Lastly, you can decide that the B shouldn't have existed, and delete
> it. This is to do with a lot of care, not only because it will discard
> the changes introduced in B, but also because if B has been pulled by
> someone else, he will have a view of history inconsistant with the
> original repository. This is done with the --force option.
To be consistent with the flow, I think you are discarding A in the
example, not B. A is what somebody else pushed out before your failed
attempt of pushing B, and --force will discard A, replacing its history
with yours.
Of course, you also could decide that somebody else's change A is vastly
superior than your crappy B, and you may decide to do "git reset --hard A"
to get rid of your history locally; but you wouldn't be using "git push"
after that. It is an equally valid outcome in the example situation and
until you fetch to see what A is, you cannot decide.
So, probably the order to teach would be:
- You can pull to merge, or pull --rebase to rebase; either way, you are
trying to preserve both histories. [I've written on this in the
previous message]
- But you may realize that the commit by the other (i.e. A) was an
incorrect solution to the same problem you solved with your B. You
_could_ force the push to replace it with B in such a case. You need
to tell the person who pushed A (and everybody else who might have
fetched A and built on top) to discard their history (and rebuild their
work that was done on top of A on top of B). [This is yours with A <=> B]
- Alternatively you may realize that the commit by the other (i.e. A) was
much better solution to the same problem you tried to solve with your
B. In such a case, you can simply discard B in your history with "git
reset --hard A" after fetching. You wouldn't be pushing anything back
in this case.
I actually do not think it is appropriate to teach --force in an example
that involves more than one person (iow, in the context of the example in
my patch). A lot better alternative in such a case is to "git merge -s
ours A" and push the result out, which keeps the fast-forwardness for the
person who did A, and others who pulled and built on top of A already.
So scratch your "lastly", replace it (and the second point in my list
above) with:
- You may realize that the commit by the other (i.e. A) was an incorrect
solution to the same problem you solved with your B. In such a case,
do _not_ use --force to remove A from the public history. Instead,
resolve the merge (in the previous instruction) favoring your solution,
e.g. "git pull -s ours", and push the result out.
next prev parent reply other threads:[~2009-08-07 20:05 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
2009-08-07 19:37 ` [PATCH] " Matthieu Moy
2009-08-07 20:05 ` Junio C Hamano [this message]
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=7vd477v17r.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Matthieu.Moy@imag.fr \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).