{"thread":{"id":"61576","subject":"git pull --ff-only errors when git merge --ff-only passes","startedAt":"2024-06-03T06:29:19Z","lastAt":"2024-06-03T21:37:55Z","messageCount":3,"participants":["Arundas T C","Junio C Hamano","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"496060","messageId":"CAKRNJbAnUBmR5MHY=uSF1A3docO-uxWG4agWuFZEyPUnduyWHw@mail.gmail.com","threadId":"61576","inReplyTo":null,"subject":"git pull --ff-only errors when git merge --ff-only passes","fromName":"Arundas T C","fromEmail":"arundas.tc@gmail.com","sentAt":"2024-06-03T06:28:41Z","receivedAt":"2024-06-03T06:29:19Z","isPatch":false,"sender":{"key":"arundas.tc@gmail.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\n1. In a remote repository, have a commit that's only in remote at the\ntip of the current branch in local.\n2. In the local clone of this repository, edit some files and have\nunstaged changes.\n3. In local, run `git pull --ff-only`.\n\nWhat did you expect to happen? (Expected behavior)\n\nFast-forward the local branch to match the remote branch, similar to\n`git merge --ff-only`. Handle any merge conflicts the same way that\n`git merge --ff-only` does.\n\nWhat happened instead? (Actual behavior)\n\nerror: cannot pull with rebase: You have unstaged changes.\nerror: Please commit or stash them.\n\nWhat's different between what you expected and what actually happened?\n\nIt errored out because of unstaged changes, even though doing `git\nmerge --ff-only` will correctly do what's expected. See below.\n\nAnything else you want to add:\n\nAfter doing `git fetch`, I can do `git merge --ff-only` and this\nfast-forwards the branch as expected. Isn't `git pull --ff-only`\nbasically the same as doing these two (fetch and merge)?\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.45.1\ncpu: arm64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58\nPDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64\ncompiler info: clang: 15.0.0 (clang-1500.3.9.4)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\npost-checkout\npost-commit\npost-merge\npre-push\n"},{"id":"496155","messageId":"xmqqo78i6o21.fsf@gitster.g","threadId":"61576","inReplyTo":"CAKRNJbAnUBmR5MHY=uSF1A3docO-uxWG4agWuFZEyPUnduyWHw@mail.gmail.com","subject":"Re: git pull --ff-only errors when git merge --ff-only passes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-06-03T15:31:02Z","receivedAt":"2024-06-03T15:31:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Arundas T C <arundas.tc@gmail.com> writes:\n\n> What happened instead? (Actual behavior)\n>\n> error: cannot pull with rebase: You have unstaged changes.\n> error: Please commit or stash them.\n>\n> What's different between what you expected and what actually happened?\n>\n> It errored out because of unstaged changes, even though doing `git\n> merge --ff-only` will correctly do what's expected. See below.\n\nBut you are not doing \"merge\" but \"rebase\", according to the error\nmessage.  \"pull\" was told to do \"rebase\" instead of \"merge\" and it\nstopped because it did not want to clobber the local changes.  So\nit appears that what \"merge --ff-only\" would have do has very little\nto do with what \"pull --ff-only\" you configured would do, no?\n\n"},{"id":"496188","messageId":"Zl417UT7n4-FQ2xj@tapette.crustytoothpaste.net","threadId":"61576","inReplyTo":"CAKRNJbAnUBmR5MHY=uSF1A3docO-uxWG4agWuFZEyPUnduyWHw@mail.gmail.com","subject":"Re: git pull --ff-only errors when git merge --ff-only passes","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2024-06-03T21:30:21Z","receivedAt":"2024-06-03T21:37:55Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2024-06-03 at 06:28:41, Arundas T C wrote:\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n> \n> What did you do before the bug happened? (Steps to reproduce your issue)\n> \n> 1. In a remote repository, have a commit that's only in remote at the\n> tip of the current branch in local.\n> 2. In the local clone of this repository, edit some files and have\n> unstaged changes.\n> 3. In local, run `git pull --ff-only`.\n> \n> What did you expect to happen? (Expected behavior)\n> \n> Fast-forward the local branch to match the remote branch, similar to\n> `git merge --ff-only`. Handle any merge conflicts the same way that\n> `git merge --ff-only` does.\n> \n> What happened instead? (Actual behavior)\n> \n> error: cannot pull with rebase: You have unstaged changes.\n> error: Please commit or stash them.\n\nThis indicates that you've set pull.rebase, so a `git pull` does a fetch\nand a rebase.\n\n> What's different between what you expected and what actually happened?\n> \n> It errored out because of unstaged changes, even though doing `git\n> merge --ff-only` will correctly do what's expected. See below.\n> \n> Anything else you want to add:\n> \n> After doing `git fetch`, I can do `git merge --ff-only` and this\n> fast-forwards the branch as expected. Isn't `git pull --ff-only`\n> basically the same as doing these two (fetch and merge)?\n\n`git merge` doesn't do a rebase.  It does a merge, which can sometimes\nbe done with a dirty tree.  `git pull` _normally_ does a fetch and a\nmerge, but in this case, you've asked it to do a fetch and a rebase,\nwhich has different constraints.  The result will almost certainly be\nidentical (since it's just a fast-forward), but rebases typically don't\nallow you to have a dirty working tree.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"}]}