All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about "git pull --rebase"
@ 2009-11-14 20:39 Francis Moreau
  2009-11-14 23:16 ` Nanako Shiraishi
  2009-11-14 23:29 ` Johan 't Hart
  0 siblings, 2 replies; 10+ messages in thread
From: Francis Moreau @ 2009-11-14 20:39 UTC (permalink / raw)
  To: git

hello,

Let's say I'm on a branch called 'foo'.

I tried to rebase this branch by using 'git pull --rebase'.

I first tried the following command:

    $ git pull --rebase origin master:foo
    remote: Counting objects: 5, done.
    remote: Total 3 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (3/3), done.
    From /dev/shm/git/A
    ! [rejected]        master     -> foo  (non fast forward)

which failed.

Then I tried:

    $ git pull --rebase origin master

which worked.

Reading the man git-pull I would assume the 2 commands are equivalent
but obviously they're not.

So the question is: why ?

Thanks
-- 
Francis

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Question about "git pull --rebase"
  2009-11-14 20:39 Question about "git pull --rebase" Francis Moreau
@ 2009-11-14 23:16 ` Nanako Shiraishi
  2009-11-15 14:31   ` Francis Moreau
  2009-11-14 23:29 ` Johan 't Hart
  1 sibling, 1 reply; 10+ messages in thread
From: Nanako Shiraishi @ 2009-11-14 23:16 UTC (permalink / raw)
  To: Francis Moreau; +Cc: git

Quoting Francis Moreau <francis.moro@gmail.com>

> Let's say I'm on a branch called 'foo'.
> ...
>     $ git pull --rebase origin master:foo

With this command line, you are asking:

 1) Please first fetch master from origin and update the local 
    'foo' with it, but please fail if this doesn't fast forward;

 2) If the first step was successful, please rebase the current 
    branch on top of that commit.

If your current branch 'foo' doesn't fast forward, the first step 
should fail, and that is the failure you saw.

Your request doesn't make any sense. The first step would succeed 
only when your 'foo' doesn't have anything to replay on 'master' 
from origin, and the second step either isn't executed (when 'foo' 
has some commits), or it doesn't do anything (when 'foo' doesn't 
have any commit).

>     $ git pull --rebase origin master

With this command line, you are asking:

 1) Please first fetch master from origin, but don't store it anywhere;

 2) Then on top of that fetched commit, please rebase the current branch.

That is a much saner request.

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Question about "git pull --rebase"
  2009-11-14 20:39 Question about "git pull --rebase" Francis Moreau
  2009-11-14 23:16 ` Nanako Shiraishi
@ 2009-11-14 23:29 ` Johan 't Hart
  2009-11-15 14:34   ` Francis Moreau
  2009-11-16 12:17   ` Francis Moreau
  1 sibling, 2 replies; 10+ messages in thread
From: Johan 't Hart @ 2009-11-14 23:29 UTC (permalink / raw)
  To: Francis Moreau; +Cc: git

Francis Moreau schreef:
 > hello,
 >
 > Let's say I'm on a branch called 'foo'.
 >
 > I tried to rebase this branch by using 'git pull --rebase'.
 >
 > I first tried the following command:
 >
 >     $ git pull --rebase origin master:foo
 >     remote: Counting objects: 5, done.
 >     remote: Total 3 (delta 0), reused 0 (delta 0)
 >     Unpacking objects: 100% (3/3), done.
 >     From /dev/shm/git/A
 >     ! [rejected]        master     -> foo  (non fast forward)

When using a refspec, you usually mean to update a remote tracking 
branch, like refs/remotes/origin/master. Internally the refspec 
parameter is passed to git fetch, which fast-forwards your local 
tracking branch to match the remote branch.

With this command, you make git clear you want to fast-forward your 
branch refs/foo to match the remotes master branch, and then rebase your 
  current branch on that foo branch.

Foo probably is also your current branch. So what you probably want is 
to fetch the remotes master branch and rebase your current branch foo on 
it. You could do it this way:

 > Then I tried:
 >
 >     $ git pull --rebase origin master
 >
 > which worked.

This does not update any remote tracking branches, but it will rebase 
your foo branch on the remote master branch (which is what you want)
It could also be done with:

git pull --rebase origin master:origin/master

This will also update your remote tracking branch 
refs/remotes/origin/master to match the master branch on the remote 
repo. Your foo branch will then be rebased onto it.

 >
 > Reading the man git-pull I would assume the 2 commands are equivalent
 > but obviously they're not.
 >
 > So the question is: why ?

So, thats why :) They're not the same. Many words... Hope you 
understand... I hope I understood it well too..?

 >
 > Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Question about "git pull --rebase"
  2009-11-14 23:16 ` Nanako Shiraishi
@ 2009-11-15 14:31   ` Francis Moreau
  0 siblings, 0 replies; 10+ messages in thread
From: Francis Moreau @ 2009-11-15 14:31 UTC (permalink / raw)
  To: Nanako Shiraishi; +Cc: git

Nanako Shiraishi <nanako3@lavabit.com> writes:

> Quoting Francis Moreau <francis.moro@gmail.com>
>
>> Let's say I'm on a branch called 'foo'.
>> ...
>>     $ git pull --rebase origin master:foo
>
> With this command line, you are asking:
>
>  1) Please first fetch master from origin and update the local 
>     'foo' with it, but please fail if this doesn't fast forward;
>
>  2) If the first step was successful, please rebase the current 
>     branch on top of that commit.
>
> If your current branch 'foo' doesn't fast forward, the first step 
> should fail, and that is the failure you saw.
>
> Your request doesn't make any sense. The first step would succeed 
> only when your 'foo' doesn't have anything to replay on 'master' 
> from origin, and the second step either isn't executed (when 'foo' 
> has some commits), or it doesn't do anything (when 'foo' doesn't 
> have any commit).
>
>>     $ git pull --rebase origin master
>
> With this command line, you are asking:
>
>  1) Please first fetch master from origin, but don't store it anywhere;
>
>  2) Then on top of that fetched commit, please rebase the current branch.
>
> That is a much saner request.

I see thanks.

Actually I've been confused by the following part of the git-pull man
page:

    A parameter <ref> without a colon is equivalent to <ref>: when
    pulling/fetching, so it merges <ref> into the current branch without
    storing the remote branch anywhere locally

So it sounds that both of the pull commands were equivalent whereas
they're not.

-- 
Francis

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Question about "git pull --rebase"
  2009-11-14 23:29 ` Johan 't Hart
@ 2009-11-15 14:34   ` Francis Moreau
  2009-11-15 19:47     ` Johan 't Hart
  2009-11-16 12:17   ` Francis Moreau
  1 sibling, 1 reply; 10+ messages in thread
From: Francis Moreau @ 2009-11-15 14:34 UTC (permalink / raw)
  To: Johan 't Hart; +Cc: git

Johan 't Hart <johanthart@gmail.com> writes:

> Francis Moreau schreef:
>> hello,
>>
>> Let's say I'm on a branch called 'foo'.
>>
>> I tried to rebase this branch by using 'git pull --rebase'.
>>
>> I first tried the following command:
>>
>>     $ git pull --rebase origin master:foo
>>     remote: Counting objects: 5, done.
>>     remote: Total 3 (delta 0), reused 0 (delta 0)
>>     Unpacking objects: 100% (3/3), done.
>>     From /dev/shm/git/A
>>     ! [rejected]        master     -> foo  (non fast forward)
>
> When using a refspec, you usually mean to update a remote tracking
> branch, like refs/remotes/origin/master. Internally the refspec
> parameter is passed to git fetch, which fast-forwards your local
> tracking branch to match the remote branch.
>
> With this command, you make git clear you want to fast-forward your
> branch refs/foo to match the remotes master branch, and then rebase
> your current branch on that foo branch.
>
> Foo probably is also your current branch. So what you probably want is
> to fetch the remotes master branch and rebase your current branch foo
> on it. You could do it this way:
>
>> Then I tried:
>>
>>     $ git pull --rebase origin master
>>
>> which worked.
>
> This does not update any remote tracking branches, but it will rebase
> your foo branch on the remote master branch (which is what you want)
> It could also be done with:
>
> git pull --rebase origin master:origin/master
>
> This will also update your remote tracking branch
> refs/remotes/origin/master to match the master branch on the remote
> repo. Your foo branch will then be rebased onto it.
>
>>
>> Reading the man git-pull I would assume the 2 commands are equivalent
>> but obviously they're not.
>>
>> So the question is: why ?
>
> So, thats why :) They're not the same. Many words... Hope you
> understand... I hope I understood it well too..?
>

Looks like you did :)

I've been somehow confused by the git-pull man page, which says:

  A parameter <ref> without a colon is equivalent to <ref>: when
  pulling/fetching, so it merges <ref> into the current branch without
  storing the remote branch anywhere locally

So I thought that both of the commands were equivalent for 'git pull
--rebase'.

Thanks for the explanation.
-- 
Francis

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Question about "git pull --rebase"
  2009-11-15 14:34   ` Francis Moreau
@ 2009-11-15 19:47     ` Johan 't Hart
  2009-11-15 20:18       ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Johan 't Hart @ 2009-11-15 19:47 UTC (permalink / raw)
  To: Francis Moreau; +Cc: git

Francis Moreau schreef:
> Looks like you did :)
> 
> I've been somehow confused by the git-pull man page, which says:
> 
>   A parameter <ref> without a colon is equivalent to <ref>: when
>   pulling/fetching, so it merges <ref> into the current branch without
>   storing the remote branch anywhere locally
> 
> So I thought that both of the commands were equivalent for 'git pull
> --rebase'.
> 
> Thanks for the explanation.

Ah that part.

It means that
$ git pull --rebase origin master

means the same as:
$ git pull --rebase origin master:
(note extra colon at the end)

But not as:
$ git pull --rebase origin master:foo

It means that, when you give a refspec without a colon, it is the same 
as the refspec with the colon and without the right side.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Question about "git pull --rebase"
  2009-11-15 19:47     ` Johan 't Hart
@ 2009-11-15 20:18       ` Junio C Hamano
  2009-11-15 20:32         ` Johan 't Hart
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2009-11-15 20:18 UTC (permalink / raw)
  To: Johan 't Hart; +Cc: Francis Moreau, git

Johan 't Hart <johanthart@gmail.com> writes:

> Francis Moreau schreef:
>> Looks like you did :)
>>
>> I've been somehow confused by the git-pull man page, which says:
>>
>>   A parameter <ref> without a colon is equivalent to <ref>: when
>>   pulling/fetching, so it merges <ref> into the current branch without
>>   storing the remote branch anywhere locally
>>
>> So I thought that both of the commands were equivalent for 'git pull
>> --rebase'.
>>
>> Thanks for the explanation.
>
> Ah that part.
>
> It means that
> $ git pull --rebase origin master
>
> means the same as:
> $ git pull --rebase origin master:
> (note extra colon at the end)
>
> But not as:
> $ git pull --rebase origin master:foo
>
> It means that, when you give a refspec without a colon, it is the same
> as the refspec with the colon and without the right side.

Thanks for clearing it up.

I was puzzled by the above pointing-finger because I wanted to see where a
misinformation originated from to fix it at the source.  But still don't
see anything wrong with it.

Perhaps there was some other part of the manual that confused Francis to
think master: and master:foo are equivalent in that context?  I somehow
doubt it, but if there is one, we would need to fix that

In a separate thread, Thomas reported a gross misinformation in github
wiki he recently fixed:

    From: Thomas Rast <trast@student.ethz.ch>
    Subject: Re: [PATCH] pull: refuse complete src:dst fetchspec arguments
    Date: Sun, 15 Nov 2009 13:24:03 +0100
    Message-ID: <200911151324.05109.trast@student.ethz.ch>

Perhaps that page had some impact on this misunderstanding? 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Question about "git pull --rebase"
  2009-11-15 20:18       ` Junio C Hamano
@ 2009-11-15 20:32         ` Johan 't Hart
  2009-11-16 12:00           ` Francis Moreau
  0 siblings, 1 reply; 10+ messages in thread
From: Johan 't Hart @ 2009-11-15 20:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Francis Moreau, git

Junio C Hamano schreef:
> Johan 't Hart <johanthart@gmail.com> writes:
>>> I've been somehow confused by the git-pull man page, which says:
>>>
>>>   A parameter <ref> without a colon is equivalent to <ref>: when
>>>   pulling/fetching, so it merges <ref> into the current branch without
>>>   storing the remote branch anywhere locally
>>>

> Thanks for clearing it up.
> 
> I was puzzled by the above pointing-finger because I wanted to see where a
> misinformation originated from to fix it at the source.  But still don't
> see anything wrong with it.
>

My guess is that he was confused by '<ref>:' not meaning '<ref>:<ref>'. 
But I can't speak for him ofcource :)

Refspecs confused me too at the beginning... But knowing more and more 
about git, it seems that this part of the docs look OK to me.. At most 
an example might make things a little more clear, but I doubt it is 
necessary.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Question about "git pull --rebase"
  2009-11-15 20:32         ` Johan 't Hart
@ 2009-11-16 12:00           ` Francis Moreau
  0 siblings, 0 replies; 10+ messages in thread
From: Francis Moreau @ 2009-11-16 12:00 UTC (permalink / raw)
  To: Johan 't Hart; +Cc: Junio C Hamano, git

On Sun, Nov 15, 2009 at 9:32 PM, Johan 't Hart <johanthart@gmail.com> wrote:
> Junio C Hamano schreef:
>>
>> Johan 't Hart <johanthart@gmail.com> writes:
>>>>
>>>> I've been somehow confused by the git-pull man page, which says:
>>>>
>>>>  A parameter <ref> without a colon is equivalent to <ref>: when
>>>>  pulling/fetching, so it merges <ref> into the current branch without
>>>>  storing the remote branch anywhere locally
>>>>
>
>> Thanks for clearing it up.
>>
>> I was puzzled by the above pointing-finger because I wanted to see where a
>> misinformation originated from to fix it at the source.  But still don't
>> see anything wrong with it.
>>
>
> My guess is that he was confused by '<ref>:' not meaning '<ref>:<ref>'. But
> I can't speak for him ofcource :)
>

Well, I don't remember how I started to think that:

<src>:

was equivalent to

<src>:<current-branch>

so, assuming I'm on branch 'foo':

$ git pull --rebase origin master:

was equivalent to

$ git pull --rebase origin master:foo

hence my confusion, which certainly due to my lack of attention
(sorry) when reading the man page.

> Refspecs confused me too at the beginning... But knowing more and more about
> git, it seems that this part of the docs look OK to me.. At most an example
> might make things a little more clear, but I doubt it is necessary.

Perhaps, the definition of a refspec with an empty string for <dst>
might be clearer if defined on its own. For example, doing this in the
git-pull man page:

      <refspec>
           The format of a <refspec> parameter is an ....

           The remote ref that matches <src> is fetched,

                  if <dst> is not empty string, the local ref that
matches it is fast
                  forwarded using <src>. If the optional plus + is
used, the local ref is
                  updated even if it does not result in a fast forward update.

                  if <dst> is an empty string the fetched <src> is
merged into the
                  current branch without updating any local refs. In
this case the
                  optional + has no meaning.

           Note
                  ....

           Some short-cut notations are also supported.

               . A parameter <src> (<ref> without the ':<dst>' part)
is equivalent
                 to '<src>:' (a ref with an empty string for <dst>).


-- 
Francis

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Question about "git pull --rebase"
  2009-11-14 23:29 ` Johan 't Hart
  2009-11-15 14:34   ` Francis Moreau
@ 2009-11-16 12:17   ` Francis Moreau
  1 sibling, 0 replies; 10+ messages in thread
From: Francis Moreau @ 2009-11-16 12:17 UTC (permalink / raw)
  To: Johan 't Hart; +Cc: git

On Sun, Nov 15, 2009 at 12:29 AM, Johan 't Hart <johanthart@gmail.com> wrote:
> This does not update any remote tracking branches, but it will rebase your
> foo branch on the remote master branch (which is what you want)
> It could also be done with:
>
> git pull --rebase origin master:origin/master
>
> This will also update your remote tracking branch refs/remotes/origin/master
> to match the master branch on the remote repo. Your foo branch will then be
> rebased onto it.

BTW, this seems to be not exact.

$ git pull --rebase origin master:origin/master

fetches the 'master' branch on the remote repo, then creates a new
branch 'origin/master', which is updated with the fetched branch.

To update the remote tracking branch refs/remotes/origin/master, I
need to issue:

$ git pull --rebase origin master:remotes/origin/master

BTW2,  it looks like if the <dst> local ref doesn't exist the it will
be created. This something that appears very lately in the man page
(actually I can see the information only in the last example). This
could be part of the <refspec> defintion.

Thanks
-- 
Francis

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-11-16 12:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-14 20:39 Question about "git pull --rebase" Francis Moreau
2009-11-14 23:16 ` Nanako Shiraishi
2009-11-15 14:31   ` Francis Moreau
2009-11-14 23:29 ` Johan 't Hart
2009-11-15 14:34   ` Francis Moreau
2009-11-15 19:47     ` Johan 't Hart
2009-11-15 20:18       ` Junio C Hamano
2009-11-15 20:32         ` Johan 't Hart
2009-11-16 12:00           ` Francis Moreau
2009-11-16 12:17   ` Francis Moreau

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.