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

Re: git pull --ff-only errors when git merge --ff-only passes

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jun 3, 2024, 21:30 UTC
Message-ID
<Zl417UT7n4-FQ2xj@tapette.crustytoothpaste.net>
In-Reply-To
<CAKRNJbAnUBmR5MHY=uSF1A3docO-uxWG4agWuFZEyPUnduyWHw@mail.gmail.com>
On 2024-06-03 at 06:28:41, Arundas T C wrote:
Show 21 quoted lines
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
> 
> What did you do before the bug happened? (Steps to reproduce your issue)
> 
> 1. In a remote repository, have a commit that's only in remote at the
> tip of the current branch in local.
> 2. In the local clone of this repository, edit some files and have
> unstaged changes.
> 3. In local, run `git pull --ff-only`.
> 
> What did you expect to happen? (Expected behavior)
> 
> Fast-forward the local branch to match the remote branch, similar to
> `git merge --ff-only`. Handle any merge conflicts the same way that
> `git merge --ff-only` does.
> 
> What happened instead? (Actual behavior)
> 
> error: cannot pull with rebase: You have unstaged changes.
> error: Please commit or stash them.

This indicates that you've set pull.rebase, so a `git pull` does a fetch and a rebase.

Show 10 quoted lines
> What's different between what you expected and what actually happened?
> 
> It errored out because of unstaged changes, even though doing `git
> merge --ff-only` will correctly do what's expected. See below.
> 
> Anything else you want to add:
> 
> After doing `git fetch`, I can do `git merge --ff-only` and this
> fast-forwards the branch as expected. Isn't `git pull --ff-only`
> basically the same as doing these two (fetch and merge)?

`git merge` doesn't do a rebase. It does a merge, which can sometimes be done with a dirty tree. `git pull` _normally_ does a fetch and a merge, but in this case, you've asked it to do a fetch and a rebase, which has different constraints. The result will almost certainly be identical (since it's just a fast-forward), but rebases typically don't allow you to have a dirty working tree.

-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA
Previous: Junio C Hamano
Message 3 of 3 in “git pull --ff-only errors when git merge --ff-only passes”
  1. Arundas T CJun 3, 2024
  2. Junio C HamanoJun 3, 2024
  3. brian m. carlsonJun 3, 2024

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.