Question about "git pull --rebase"

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Question about "git pull --rebase"

From: Francis Moreau <hidden>
Date: 2016-06-15 22:47:43

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

Re: Question about "git pull --rebase"

From: Nanako Shiraishi <hidden>
Date: 2016-06-15 22:47:43

Quoting Francis Moreau [off-list ref]
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/

Re: Question about "git pull --rebase"

From: Johan 't Hart <hidden>
Date: 2016-06-15 22:47:43

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

Re: Question about "git pull --rebase"

From: Francis Moreau <hidden>
Date: 2016-06-15 22:47:43

On Sun, Nov 15, 2009 at 12:29 AM, Johan 't Hart [off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help