From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
"brian m. carlson" <sandals@crustytoothpaste.net>
Cc: Alex Henrie <alexhenrie24@gmail.com>,
git@vger.kernel.org, sunshine@sunshineco.com
Subject: Re: [PATCH v2] Give git-pull a --reset option
Date: Mon, 22 Apr 2019 16:14:34 +0100 [thread overview]
Message-ID: <02595523-3b16-b434-1ea9-a9399d7f1783@gmail.com> (raw)
In-Reply-To: <xmqqftqb9bf1.fsf@gitster-ct.c.googlers.com>
On 22/04/2019 00:38, Junio C Hamano wrote:
> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
>
>> It may be helpful to point out that this is essentially the workflow I
>> had ...
>> I'm not sure if this email is an argument for or against this option,
>> but maybe it provides some helpful perspective.
>
> I think you and Phillip misread me.
>
> I did not question if the workflow is common the message you are
> responding to. I've done my fair share of "I know what I have on my
> laptop is stale as I pushed it out to elsewhere to continue working
> on it, so let's get rid of it from the updated upstream and start
> afresh" myself.
>
> What I questioned was if it is sensible to ensure that it stays
> common.
>
> We'd be encouraging the dangerous workflow, instead of analysing the
> situation where people employ it and trying to give them a better
> alternative to deal with the situation.
I agree that it would be better to support this workflow in a safer
manner. I use a script that looks at the reflog of the local and remote
branches to work out if it is safe to reset --hard when pulling. If
there are local changes since the last push/pull (because I forget to
sync before starting work) then it will run rebase --onto <new-remote>
<last-sync>. If the remote branch and local branches have both been
rewritten it tells me to run range-diff to figure out how to fix it.
The value of <last-sync> is the most recent push or pull that updated
the local branch. i.e. when both the local and remote refs pointed to
the same commit at the same time (rebase complicates this as the remote
we rebased onto does not appear in directly the local reflog - you have
to look for "rebase .*finish.* <local-ref> <remote-oid>". Also an ide
might auto fetch and update the remote ref while we're rebasing the
local work which stops the reflog coinciding exactly.) The <last-sync>
is also useful for making forced pushes safer. The script pushes with
--force-with-lease=<ref>:<last-sync> if the local branch has been
rewritten since the last sync so that any remote changes since the last
sync are not overwritten.
Using the reflog to figure out the last sync makes forced pushes and
pulls much safer. If we want to support this workflow in core git (and
it does seem to be fairly common) then I think it needs to be based on
something that prevents people from accidentally throwing away local
changes when pulling and remote changes when pushing. There was some
discussion of this with respect to pushing last summer[1]
Best Wishes
Phillip
[1]
https://public-inbox.org/git/CAEFop40OJ5MRwM8zxE44yB0f2Fxw9YsUdM1e-H=Nn9e=sAGJ=w@mail.gmail.com/T/#u
That is what we'd be doing
> with "pull --reset", i.e. an easier to type short-hand that robs the
> chance to double check in the middle of "fetch && inspect && reset"
> sequence.
>
> As to where the feature should go, if we decide that it is a good
> idea to promote this workflow element as a supported feature, I
> agree with Alex's design in the patch that it makes sense to have it
> as "pull --reset". Existing "pull --merge" and "pull -rebase" are
> "fetch and then integrate by merging theirs into ours" and "fetch
> and then integrate by rebasing our stuff on top of theirs"; the new
> "pull --reset" would fit well sitting next to them with its "fetch
> and then treat our stuff as valueless and replace it with theirs"
> semantics.
>
prev parent reply other threads:[~2019-04-22 15:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-21 4:08 [PATCH v2] Give git-pull a --reset option Alex Henrie
2019-04-21 5:38 ` Junio C Hamano
2019-04-21 7:01 ` Alex Henrie
2019-04-21 13:53 ` Philip Oakley
2019-04-21 21:18 ` brian m. carlson
2019-04-21 23:38 ` Junio C Hamano
2019-04-22 15:14 ` Phillip Wood [this message]
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=02595523-3b16-b434-1ea9-a9399d7f1783@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=alexhenrie24@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=sandals@crustytoothpaste.net \
--cc=sunshine@sunshineco.com \
/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).