From: John Keeping <john@keeping.me.uk>
To: Mike Botsko <botsko@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: Unexpected/unexplained difference between git pull --rebase and git rebase
Date: Tue, 3 Mar 2015 23:40:57 +0000 [thread overview]
Message-ID: <20150303234057.GR890@serenity.lan> (raw)
In-Reply-To: <CAPfvZp5jTTbWVL0QuZTP83=SWvsvyZWX0BG_q7jPLK5wNNvCgg@mail.gmail.com>
On Tue, Mar 03, 2015 at 03:20:48PM -0800, Mike Botsko wrote:
> Maybe I'm lacking the distinction regarding what I'm being specific about.
>
> In both examples, I'm asking it specifically to rebase in changes from
> the remote "upstream" and a named branch at that location. I'm giving
> git the same information, it's just interpreting it differently - and
> I'm not understanding why.
Not quite. If you say:
git rebase $sha1
then you're telling git-rebase to apply the commits $sha1..HEAD onto
$sha1.
If you say:
git rebase
then it will be re-written as:
git rebase --fork-point @{upstream}
in which case Git will apply more complicated logic so that you can
recover from the case where @{upstream} has been re-written.
Consider the following scenario:
F branch
/
C -- D master@{1}
/
A -- B -- C' -- D' -- E master
where C' and D' are rewritten versions of C and D.
In this case, imagine you are at F on "branch", "git rebase master" will
replace C, D and F onto E because you have explicitly selected to replay
master..branch onto master.
"git rebase" will apply the fork-point logic and realise that D is a
previous version of master, so it will only replay F onto E.
In general if you just want to rebase onto your upstream it is simpler
to just call "git rebase" which will do the right thing; it's also
shorter to type ;-)
> My local branch would have been created from the
> upstream/feature-branch, and will eventually be merged back into it.
> Until I'm ready for that, I regularly rebase the work done on
> upstream/feature-branch so that my local work is always clean and
> above anything else.
In this case the problem stems from the fact that
upstream/feature-branch has been rewritten. Building on top of branches
that will be rewritten is not advisable unless you have a really good
reason to do so.
> On Tue, Mar 3, 2015 at 3:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
> > John Keeping <john@keeping.me.uk> writes:
> >
> >> git-rebase assumes that if you give an explicit upstream then you want
> >> precisely what you asked for. From git-rebase(1):
> >>
> >> If either <upstream> or --root is given on the command line,
> >> then the default is `--no-fork-point`, otherwise the default is
> >> `--fork-point`.
> >
> > Correct.
> >
> > You ask it to rebase the history without guessing by being explicit;
> > the command guesses when you are not explicit and being lazy ;-).
next prev parent reply other threads:[~2015-03-03 23:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-03 20:39 Unexpected/unexplained difference between git pull --rebase and git rebase Mike Botsko
2015-03-03 21:09 ` John Keeping
2015-03-03 21:31 ` Mike Botsko
2015-03-03 21:46 ` John Keeping
2015-03-03 23:15 ` Junio C Hamano
2015-03-03 23:20 ` Mike Botsko
2015-03-03 23:40 ` John Keeping [this message]
2015-03-03 23:54 ` Mike Botsko
2015-03-04 9:35 ` John Keeping
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=20150303234057.GR890@serenity.lan \
--to=john@keeping.me.uk \
--cc=botsko@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.