{"thread":{"id":"55415","subject":"Branches, upstreams, rebases and logistics","startedAt":"2021-03-30T20:29:53Z","lastAt":"2021-03-31T11:34:50Z","messageCount":2,"participants":["stdedos@gmail.com","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"420649","messageId":"20210330202852.9673-1-stdedos+git@gmail.com","threadId":"55415","inReplyTo":null,"subject":"Branches, upstreams, rebases and logistics","fromName":"","fromEmail":"stdedos@gmail.com","sentAt":"2021-03-30T20:28:52Z","receivedAt":"2021-03-30T20:29:53Z","isPatch":false,"sender":{"key":"stdedos@gmail.com","avatar":null},"body":"I was reading this thread:\nhttps://lore.kernel.org/git/YFP+KuUn99vftBIC@camp.crustytoothpaste.net/\n\nand, in specific:\n> ..., many fixup and squash commits and near constant rebases.\n\nwhich speaks to me somewhat heavily.\n\nAs this could be a discussion forum, I'd like to see\nhow other people are dealing with / have done for these:\n\nI clone a repository, I do changes on top of a branch,\nI push for review, ... and the cycle continues until merging.\n\nIt is trivial, when native `git push/pull` is used to push/pull\nto/from one remote which I have access, as `pull --rebase` works\nmagically in keeping the local state up-to-date.\n\nIt also works with the repos that you do not have direct access to\npush natively on the branch nowhere, as you can keep using the\n`pull --rebase` to sync, and \"push\" with some other method\n(`refs/for`, `git-send-email`, or others which I don't know).\n\nHowever, with the Github way of working, that means:\nI have two remotes, (origin and upstream), on which, I develop and\npush on the `origin`, but I am really tracking/rebasing on/from `upstream`.\n\nI cannot `--track` upstream, as plain `git push` won't work, and\nfor pull, I have to separately `git fetch --all`, `git rebase upstream/<branch>`\n\n- OR -\n\nI have a branch, which depends on top of another branch (not yet merged upstream).\n\no - origin/master\n \\\n  o---o---o---o\n  |            \\\n  fix/local     o--o - (fix/depends-on-local)\n\nFor brevity, I am setting \"git branch --set-upstream-to=fix/local\",\nwhich helps, when rebasing fix/local on top of origin/master, to rebase\nfix/depends-on-local on top of fix/local.\n\nHowever, as noted above, a branch cannot be pushed upstream easily and\nhave a different upstream set at the same time.\n\nI know my logic/understanding is lacking somewhere;\nI am looking forward to enlightenment :-D\n"},{"id":"420703","messageId":"YGRdtHjaL5l5v5Ym@coredump.intra.peff.net","threadId":"55415","inReplyTo":"20210330202852.9673-1-stdedos+git@gmail.com","subject":"Re: Branches, upstreams, rebases and logistics","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-03-31T11:32:04Z","receivedAt":"2021-03-31T11:34:50Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Mar 30, 2021 at 11:28:52PM +0300, stdedos@gmail.com wrote:\n\n> However, with the Github way of working, that means:\n> I have two remotes, (origin and upstream), on which, I develop and\n> push on the `origin`, but I am really tracking/rebasing on/from `upstream`.\n> \n> I cannot `--track` upstream, as plain `git push` won't work, and\n> for pull, I have to separately `git fetch --all`, `git rebase upstream/<branch>`\n> \n> - OR -\n> \n> I have a branch, which depends on top of another branch (not yet merged upstream).\n> \n> o - origin/master\n>  \\\n>   o---o---o---o\n>   |            \\\n>   fix/local     o--o - (fix/depends-on-local)\n> \n> For brevity, I am setting \"git branch --set-upstream-to=fix/local\",\n> which helps, when rebasing fix/local on top of origin/master, to rebase\n> fix/depends-on-local on top of fix/local.\n> \n> However, as noted above, a branch cannot be pushed upstream easily and\n> have a different upstream set at the same time.\n\nThis is usually called a \"triangular\" workflow; you can find some\ndiscussion in the list archive and documentation by searching for that\nterm.\n\nBut in short, what you probably want is to set:\n\n  git config remote.pushdefault yourfork\n\n(I'm not entirely sure, but I think \"yourfork\" is \"origin\" in your\nexample). Which means that \"git push\" will behave as you'd like, pushing\nto your fork. And you are free to set the \"upstream\" of each branch to\nthe thing it is based on (again, assuming your \"upstream\" remote is the\nactual upstream project that you can't push to):\n\n  git branch --set-upstream-to=upstream/master fix/local\n  git branch --set-upstream-to=fix/local fix/depends-on-local\n\nAnd then from either \"fix/local\" or \"fix/depends-on-local\" branches, you\ncan \"git pull --rebase\" (or in the case of the latter, just \"git rebase\"\nwould do the same thing).\n\n-Peff\n"}]}