{"thread":{"id":"59617","subject":"Git rebase no longer defaults to upstream after force push","startedAt":"2023-04-18T09:18:37Z","lastAt":"2023-04-19T17:04:09Z","messageCount":6,"participants":["Erik Cervin Edin","Phillip Wood","Cem Gündoğdu","Felipe Contreras","Sergey Organov"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"475601","messageId":"CA+JQ7M_KuDXBaVTzVwLTx+R4-6-3TOuUOpcchkS26iiosc85Hg@mail.gmail.com","threadId":"59617","inReplyTo":null,"subject":"Git rebase no longer defaults to upstream after force push","fromName":"Erik Cervin Edin","fromEmail":"erik@cervined.in","sentAt":"2023-04-18T09:17:42Z","receivedAt":"2023-04-18T09:18:37Z","isPatch":false,"sender":{"key":"erik@cervined.in","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\n  git init --bare foo.git && git clone foo.git/ foo && cd foo\n  touch bar && git add bar && git commit -m init\n  git push -u\n  git switch -c a\n  seq 1 3 > bar && git add bar && git commit -m 1\n  git push\n  seq 11 13 > bar && git add bar && git commit -m 2\n  git rebase -ir # Works like git rebase -ir @{upstream}\n  git push --force origin main:a\n  git rebase -ir # No longer works like git rebase -ir @{upstream}\n\nWhat did you expect to happen? (Expected behavior)\n\nAfter force pushing, I still expected the rebase to work like git\nrebase -ir @{upstream}.\n\nWhat happened instead? (Actual behavior)\n\nThe rebase defaults to a commit other than that of the tip of the\nupstream branch.\n\nWhat's different between what you expected and what actually happened?\n\nInstead of behaving like git rebase @{upstream}, the rebase seems to\ndefault to rebasing on-top of the old upstream.\n\ngit rebase -ir result in a todo like this:\n\nl onto\n\nt onto\np f1cfbff 2023-04-18    2\n\nCompared to git rebase -ir @{upstream} which results in a todo like this:\n\nl onto\n\nt onto\np 01e3c92 2023-04-18    1\np f1cfbff 2023-04-18    2\n\nAnything else you want to add:\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.40.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27\n02:56:13 UTC 2023 x86_64\ncompiler info: gnuc: 11.3\nlibc info: glibc: 2.35\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n\n-- \nErik Cervin-Edin\n"},{"id":"475614","messageId":"788c85f0-1381-4d37-cb23-dd67f26a5b6a@gmail.com","threadId":"59617","inReplyTo":"CA+JQ7M_KuDXBaVTzVwLTx+R4-6-3TOuUOpcchkS26iiosc85Hg@mail.gmail.com","subject":"Re: Git rebase no longer defaults to upstream after force push","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2023-04-18T14:01:41Z","receivedAt":"2023-04-18T14:02:29Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Erik\n\nThanks for reporting this, unfortunately without knowing more about your \nconfig settings it is hard to tell what is happening here.\n\nOn 18/04/2023 10:17, Erik Cervin Edin 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>    git init --bare foo.git && git clone foo.git/ foo && cd foo\n>    touch bar && git add bar && git commit -m init\n>    git push -u\n\nThis sets the upstream branch for main to origin/main, (assuming \npush.default allows pushing without specifying a refspec)\n\n>    git switch -c a\n\nHere you create a new branch, whether switch sets an upstream for it \ndepends on the value of branch.autoSetupMerge. The default is not to set \nan upstream branch in this case. If you have set branch.autoSetupMerge \nto \"always\" then the upstream branch will be \"main\", if \nbranch.autoSetupMerge is set to \"inherit\" then the upstream branch will \nbe \"origin/main\". What does branch -vv show?\n\n>    seq 1 3 > bar && git add bar && git commit -m 1\n>    git push\n\nWhat happens here depends on push.default, branch.autoSetupMerge and \npush.autoSetupRemote. If switch did not set an upstream branch then push \nwill if you have push.autoSetupRemote enabled.\n\n>    seq 11 13 > bar && git add bar && git commit -m 2\n>    git rebase -ir # Works like git rebase -ir @{upstream}\n>    git push --force origin main:a\n>    git rebase -ir # No longer works like git rebase -ir @{upstream}\n\nWithout knowing what the upstream branch is it is hard to say what is \ngoing on here.\n\nBest Wishes\n\nPhillip\n\n> What did you expect to happen? (Expected behavior)\n> \n> After force pushing, I still expected the rebase to work like git\n> rebase -ir @{upstream}.\n> \n> What happened instead? (Actual behavior)\n> \n> The rebase defaults to a commit other than that of the tip of the\n> upstream branch.\n> \n> What's different between what you expected and what actually happened?\n> \n> Instead of behaving like git rebase @{upstream}, the rebase seems to\n> default to rebasing on-top of the old upstream.\n> \n> git rebase -ir result in a todo like this:\n> \n> l onto\n> \n> t onto\n> p f1cfbff 2023-04-18    2\n> \n> Compared to git rebase -ir @{upstream} which results in a todo like this:\n> \n> l onto\n> \n> t onto\n> p 01e3c92 2023-04-18    1\n> p f1cfbff 2023-04-18    2\n> \n> Anything else you want to add:\n> \n> Please review the rest of the bug report below.\n> You can delete any lines you don't wish to share.\n> \n> \n> [System Info]\n> git version:\n> git version 2.40.0\n> cpu: x86_64\n> no commit associated with this build\n> sizeof-long: 8\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> uname: Linux 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27\n> 02:56:13 UTC 2023 x86_64\n> compiler info: gnuc: 11.3\n> libc info: glibc: 2.35\n> $SHELL (typically, interactive shell): /bin/bash\n> \n> \n> [Enabled Hooks]\n> \n"},{"id":"475628","messageId":"CAGrwipO7odTbuKgwDmU+3hY0pEeTdjxx-_9=oufUdBzyQ_eRvQ@mail.gmail.com","threadId":"59617","inReplyTo":"CA+JQ7M_KuDXBaVTzVwLTx+R4-6-3TOuUOpcchkS26iiosc85Hg@mail.gmail.com","subject":"Re: Git rebase no longer defaults to upstream after force push","fromName":"Cem Gündoğdu","fromEmail":"cscallsign@gmail.com","sentAt":"2023-04-18T15:54:13Z","receivedAt":"2023-04-18T15:54:38Z","isPatch":false,"sender":{"key":"cscallsign@gmail.com","avatar":null},"body":"Hi Erik,\n\nFrom documentation:\n\n> If <upstream> is not specified, [...] and the --fork-point option is assumed.\n\nThe --fork-point option does this:\n\n> Use reflog to find a better common ancestor between <upstream> and <branch> when calculating which commits have been introduced by <branch>.\n\nSince the parent of a is still in the reflog of origin/a, it is not\nbeing rebased (the rationale being that the commit *was* in origin/a\nat some point). If you want to disable this behavior, add\n--no-fork-point option:\n\ngit rebase -ir --no-fork-point\n\nSince this is the documented behavior, it probably is not a bug.\n\nBest,\nCem\n\nOn Tue, Apr 18, 2023 at 11:34 AM Erik Cervin Edin <erik@cervined.in> wrote:\n>\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>   git init --bare foo.git && git clone foo.git/ foo && cd foo\n>   touch bar && git add bar && git commit -m init\n>   git push -u\n>   git switch -c a\n>   seq 1 3 > bar && git add bar && git commit -m 1\n>   git push\n>   seq 11 13 > bar && git add bar && git commit -m 2\n>   git rebase -ir # Works like git rebase -ir @{upstream}\n>   git push --force origin main:a\n>   git rebase -ir # No longer works like git rebase -ir @{upstream}\n>\n> What did you expect to happen? (Expected behavior)\n>\n> After force pushing, I still expected the rebase to work like git\n> rebase -ir @{upstream}.\n>\n> What happened instead? (Actual behavior)\n>\n> The rebase defaults to a commit other than that of the tip of the\n> upstream branch.\n>\n> What's different between what you expected and what actually happened?\n>\n> Instead of behaving like git rebase @{upstream}, the rebase seems to\n> default to rebasing on-top of the old upstream.\n>\n> git rebase -ir result in a todo like this:\n>\n> l onto\n>\n> t onto\n> p f1cfbff 2023-04-18    2\n>\n> Compared to git rebase -ir @{upstream} which results in a todo like this:\n>\n> l onto\n>\n> t onto\n> p 01e3c92 2023-04-18    1\n> p f1cfbff 2023-04-18    2\n>\n> Anything else you want to add:\n>\n> Please review the rest of the bug report below.\n> You can delete any lines you don't wish to share.\n>\n>\n> [System Info]\n> git version:\n> git version 2.40.0\n> cpu: x86_64\n> no commit associated with this build\n> sizeof-long: 8\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> uname: Linux 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27\n> 02:56:13 UTC 2023 x86_64\n> compiler info: gnuc: 11.3\n> libc info: glibc: 2.35\n> $SHELL (typically, interactive shell): /bin/bash\n>\n>\n> [Enabled Hooks]\n>\n> --\n> Erik Cervin-Edin\n"},{"id":"475676","messageId":"643f30851cd53_2217c42948e@chronos.notmuch","threadId":"59617","inReplyTo":"CA+JQ7M_KuDXBaVTzVwLTx+R4-6-3TOuUOpcchkS26iiosc85Hg@mail.gmail.com","subject":"Re: Git rebase no longer defaults to upstream after force push","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-04-19T00:06:29Z","receivedAt":"2023-04-19T00:06:38Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Erik Cervin Edin 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>   git init --bare foo.git && git clone foo.git/ foo && cd foo\n>   touch bar && git add bar && git commit -m init\n>   git push -u\n>   git switch -c a\n>   seq 1 3 > bar && git add bar && git commit -m 1\n>   git push\n\nFor me it fails at this point.\n\n  fatal: The upstream branch of your current branch does not match\n  the name of your current branch.  To push to the upstream branch\n  on the remote, use\n\n      git push . HEAD:master\n\n  To push to the branch of the same name on the remote, use\n\n      git push . HEAD\n\n  To choose either option permanently, see push.default in 'git help config'.\n\n  To avoid automatically configuring an upstream branch when its name\n  won't match the local branch, see option 'simple' of branch.autoSetupMerge\n  in 'git help config'.\n\nWhat's your configured push.default?\n\n>   seq 11 13 > bar && git add bar && git commit -m 2\n>   git rebase -ir # Works like git rebase -ir @{upstream}\n>   git push --force origin main:a\n>   git rebase -ir # No longer works like git rebase -ir @{upstream}\n\nThis works fine here.\n\n-- \nFelipe Contreras\n"},{"id":"475701","messageId":"CA+JQ7M_XP6fjdut10ry9db9M3pEhp3-+zToJ93gnbHo-4p_8uQ@mail.gmail.com","threadId":"59617","inReplyTo":"CAGrwipO7odTbuKgwDmU+3hY0pEeTdjxx-_9=oufUdBzyQ_eRvQ@mail.gmail.com","subject":"Re: Git rebase no longer defaults to upstream after force push","fromName":"Erik Cervin Edin","fromEmail":"erik@cervined.in","sentAt":"2023-04-19T15:43:10Z","receivedAt":"2023-04-19T15:44:20Z","isPatch":false,"sender":{"key":"erik@cervined.in","avatar":null},"body":"On Tue, Apr 18, 2023 at 5:54 PM Cem Gündoğdu <cscallsign@gmail.com> wrote:\n> > If <upstream> is not specified, [...] and the --fork-point option is assumed.\n>\n> The --fork-point option does this:\n>\n> > Use reflog to find a better common ancestor between <upstream> and <branch> when calculating which commits have been introduced by <branch>.\n>\n> Since the parent of a is still in the reflog of origin/a, it is not\n> being rebased (the rationale being that the commit *was* in origin/a\n> at some point). If you want to disable this behavior, add\n> --no-fork-point option:\n\nYes. That's it, thank you for pointing out --fork-point. That's indeed\nwhat's causing the unexpected behavior.\n\nDo you happen to know when such behavior is desirable? I'm tempted to\nchange the default to --no-fork-point but usually when something is\ndefault there's a valid reason.. 🤔\n"},{"id":"475707","messageId":"87ttxbztvl.fsf@osv.gnss.ru","threadId":"59617","inReplyTo":"CA+JQ7M_XP6fjdut10ry9db9M3pEhp3-+zToJ93gnbHo-4p_8uQ@mail.gmail.com","subject":"Re: Git rebase no longer defaults to upstream after force push","fromName":"Sergey Organov","fromEmail":"sorganov@gmail.com","sentAt":"2023-04-19T17:03:58Z","receivedAt":"2023-04-19T17:04:09Z","isPatch":false,"sender":{"key":"sorganov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8501568?v=4"},"body":"Erik Cervin Edin <erik@cervined.in> writes:\n\n> On Tue, Apr 18, 2023 at 5:54 PM Cem Gündoğdu <cscallsign@gmail.com> wrote:\n>> > If <upstream> is not specified, [...] and the --fork-point option is assumed.\n>>\n>> The --fork-point option does this:\n>>\n>> > Use reflog to find a better common ancestor between <upstream> and\n>> > <branch> when calculating which commits have been introduced by\n>> > <branch>.\n>>\n>> Since the parent of a is still in the reflog of origin/a, it is not\n>> being rebased (the rationale being that the commit *was* in origin/a\n>> at some point). If you want to disable this behavior, add\n>> --no-fork-point option:\n>\n> Yes. That's it, thank you for pointing out --fork-point. That's indeed\n> what's causing the unexpected behavior.\n>\n> Do you happen to know when such behavior is desirable? I'm tempted to\n> change the default to --no-fork-point but usually when something is\n> default there's a valid reason.. 🤔\n\n$ git help merge-base\n\nhas a thorough discussion of --fork-point that might be helpful.\n\nAs far as I understand, it helps to DWYM when remote branch has been\nrewound, and causes nasty confusion when it fires unintentionally. \n\n-- Sergey\n"}]}