git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Question about "git pull --rebase"

From
Johan 't Hart <johanthart@gmail.com>
Date
Nov 14, 2009, 23:29 UTC
Message-ID
<4AFF3D4D.7000308@gmail.com>
In-Reply-To
<38b2ab8a0911141239w2bab7277o66350bc742d985dd@mail.gmail.com>
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
Previous: Francis MoreauNext: Francis Moreau
Message 4 of 10 in “Question about "git pull --rebase"”
  1. Francis MoreauNov 14, 2009
  2. Nanako ShiraishiNov 14, 2009
  3. Francis MoreauNov 15, 2009
  4. Johan 't HartNov 14, 2009
  5. Francis MoreauNov 15, 2009
  6. Johan 't HartNov 15, 2009
  7. Junio C HamanoNov 15, 2009
  8. Johan 't HartNov 15, 2009
  9. Francis MoreauNov 16, 2009
  10. Francis MoreauNov 16, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.