{"thread":{"id":"62826","subject":"Rebase","startedAt":"2025-01-19T05:29:23Z","lastAt":"2025-01-20T21:15:16Z","messageCount":6,"participants":["Al Grant","brian m. carlson","D. Ben Knoble"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"510885","messageId":"CAODtcdcTjquNUBaTWKzyy54J5NoH7WO+9uMzJ+wWRDf0Na3OPA@mail.gmail.com","threadId":"62826","inReplyTo":null,"subject":"Rebase","fromName":"Al Grant","fromEmail":"bigal.nz@gmail.com","sentAt":"2025-01-19T05:29:09Z","receivedAt":"2025-01-19T05:29:23Z","isPatch":false,"sender":{"key":"bigal.nz@gmail.com","avatar":null},"body":"Hello,\n\nI am looking for some assistance rebasing please.\n\nI have a feature branch which has the many recent commits and a main\nbranch which has not had a commit for a long time. I want to make the\ncode in the feature branch the code in the main branch.\n\nI think a rebase is the command I need, but the exact steps I am not sure of.\n\nI did try this:\n\n1. Sync both branches with remote (github)\n2. git checkout feature\n3. git rebase main\n\nThat resulted in the following perge conflicts:\n\nPS C:\\Users\\AlGrant\\andrej_branch\\test_fft> git rebase main\nerror: could not apply 1f893dc... Make project runnable on Linux\nResolve all conflicts manually, mark them as resolved with\n\"git add/rm <conflicted_files>\", then run \"git rebase --continue\".\nYou can instead skip this commit: run \"git rebase --skip\".\nTo abort and get back to the state before \"git rebase\", run \"git\nrebase --abort\".\nCould not apply 1f893dc... Make project runnable on Linux\nAuto-merging src/kiwitracker/sample_processor.py\nCONFLICT (content): Merge conflict in src/kiwitracker/sample_processor.py\nAuto-merging src/kiwitracker/common.py\nCONFLICT (content): Merge conflict in src/kiwitracker/common.py\nPS C:\\Users\\AlGrant\\andrej_branch\\test_fft> git rebase --abort\n\nWhich I have now aborted. I dont understand why I even have to deal\nwith merge conflicts when I want to keep the code in feature and make\nit main.\n\nHelp.\n\nThanks\n\nAl\n"},{"id":"510910","messageId":"Z40mlmfnUOXI2ghd@tapette.crustytoothpaste.net","threadId":"62826","inReplyTo":"CAODtcdcTjquNUBaTWKzyy54J5NoH7WO+9uMzJ+wWRDf0Na3OPA@mail.gmail.com","subject":"Re: Rebase","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-01-19T16:21:42Z","receivedAt":"2025-01-19T16:21:44Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-01-19 at 05:29:09, Al Grant wrote:\n> Hello,\n> \n> I am looking for some assistance rebasing please.\n> \n> I have a feature branch which has the many recent commits and a main\n> branch which has not had a commit for a long time. I want to make the\n> code in the feature branch the code in the main branch.\n> \n> I think a rebase is the command I need, but the exact steps I am not sure of.\n> \n> I did try this:\n> \n> 1. Sync both branches with remote (github)\n> 2. git checkout feature\n> 3. git rebase main\n\nIf you just want to make the branches completely identical, you can do\nthis:\n\n----\n$ git checkout feature\n$ git update-ref refs/heads/main $(git rev-parse --verify refs/heads/feature)\n----\n\nThat will make `main` the exact same commit as `feature`.  Note that you\ndon't want to be on the destination branch (in this case, `main`) when\nyou do the `git update-ref` call because that will result in the index\nbeing out of sync with the commit.\n\nYou could also do this:\n\n----\n$ git checkout main\n$ git reset --hard feature\n----\n\nThat will update `main` and the working tree to be completely identical\nto `feature`.  Please note that it will also completely and\nirrecoverably destroy changes in any modified files in the working tree,\nso you may prefer the first option, which is a little safer.\n\nIn either case, if there are changes in the `main` branch which are not\nin the `feature` branch, this will remove them.  What I gave you above\nwill make them completely identical in every way, including in terms of\nhistory.\n\nIf you want to preserve some of those changes, then you do need a\nrebase, and the commands you gave are correct.  You will then need to\nresolve the merge conflicts in each conflicting commit and continue the\nrebase each time.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"},{"id":"510912","messageId":"CAODtcdfS+TVmrwohtHFUXRZRwC1WmF5ENpZLVoZTyJgA--SC-Q@mail.gmail.com","threadId":"62826","inReplyTo":"CAODtcdf-+QpPpB5R-hLkKWKacwM=N3=XRDs-tK60W9WzUJu7xw@mail.gmail.com","subject":"Re: Rebase","fromName":"Al Grant","fromEmail":"bigal.nz@gmail.com","sentAt":"2025-01-19T20:39:13Z","receivedAt":"2025-01-19T20:39:26Z","isPatch":false,"sender":{"key":"bigal.nz@gmail.com","avatar":null},"body":"Yes. But I'm keen to understand how to deal with a merge conflict.\n\nMy IDE is VSCode and when I run the merge I get this image:\n\nhttps://imgur.com/a/vynTxaj\n\nWhich highlights this code:\n\n255: <<<<<<< HEAD\n256:        samples = signal.convolve(samples, [1]*189, 'same')/189\n257:\n258:        #for testing - log to file\n259:        #self.f.write(samples.astype(np.float32).tobytes())\n260:\n261:=======\n262:        samples = signal.convolve(samples, [1] * 10, \"same\") / 189\n263:\n264:        # for testing - log to file\n265:        # self.f.write(samples.astype(np.float32).tobytes())\n266:\n267:>>>>>>> 1f893dc (Make project runnable on Linux)\n\nNow I would assume that samples = .... from ln 256 abd 262 are the\ndifferences between MAIN and FEATURE?\n\nBut when I search main (at least I think its main - my IDE doesnt tell\nme mid rebase process) for ` samples = signal.convolve(samples,\n[1]*189, 'same')/189` AND `samples = signal.convolve(samples, [1] *\n10, \"same\") / 189` - those lines do not exists anywhere in MAIN???\n\nSo what is going on????\n\nAl\n"},{"id":"510914","messageId":"CALnO6CDwL3XHwMhHbX+7C87-pX+RBRDt3djKfr3LpqTFKpPV1A@mail.gmail.com","threadId":"62826","inReplyTo":"CAODtcdfS+TVmrwohtHFUXRZRwC1WmF5ENpZLVoZTyJgA--SC-Q@mail.gmail.com","subject":"Re: Rebase","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2025-01-19T23:08:11Z","receivedAt":"2025-01-19T23:08:24Z","isPatch":false,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On Sun, Jan 19, 2025 at 3:39 PM Al Grant <bigal.nz@gmail.com> wrote:\n>\n> Yes. But I'm keen to understand how to deal with a merge conflict.\n\n[and also]\n\n> Which I have now aborted. I dont understand why I even have to deal\nwith merge conflicts when I want to keep the code in feature and make\nit main.\n\nI recommend reading the book, esp.\nhttps://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts.\nThere is also an advanced section\nhttps://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging.\n\nAs for why you get a merge conflict when rebasing, see for example the\nStackOverflow about rebase using a 3-way merge\n(https://stackoverflow.com/q/36993683/4400820) or part of the\nremembering-renames documentation\n(https://git-scm.com/docs/remembering-renames, but it renders poorly,\nso also try `open $(git\n--html-path)/technical/remembering-renames.txt`, substituting `open`\nfor your platform equivalent).\n\n\n-- \nD. Ben Knoble\n"},{"id":"510916","messageId":"Z42nq54yuWqiU4t6@tapette.crustytoothpaste.net","threadId":"62826","inReplyTo":"CAODtcdfS+TVmrwohtHFUXRZRwC1WmF5ENpZLVoZTyJgA--SC-Q@mail.gmail.com","subject":"Re: Rebase","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-01-20T01:32:27Z","receivedAt":"2025-01-20T01:32:35Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-01-19 at 20:39:13, Al Grant wrote:\n> Yes. But I'm keen to understand how to deal with a merge conflict.\n> \n> My IDE is VSCode and when I run the merge I get this image:\n> \n> https://imgur.com/a/vynTxaj\n> \n> Which highlights this code:\n> \n> 255: <<<<<<< HEAD\n> 256:        samples = signal.convolve(samples, [1]*189, 'same')/189\n> 257:\n> 258:        #for testing - log to file\n> 259:        #self.f.write(samples.astype(np.float32).tobytes())\n> 260:\n> 261:=======\n> 262:        samples = signal.convolve(samples, [1] * 10, \"same\") / 189\n> 263:\n> 264:        # for testing - log to file\n> 265:        # self.f.write(samples.astype(np.float32).tobytes())\n> 266:\n> 267:>>>>>>> 1f893dc (Make project runnable on Linux)\n> \n> Now I would assume that samples = .... from ln 256 abd 262 are the\n> differences between MAIN and FEATURE?\n> \n> But when I search main (at least I think its main - my IDE doesnt tell\n> me mid rebase process) for ` samples = signal.convolve(samples,\n> [1]*189, 'same')/189` AND `samples = signal.convolve(samples, [1] *\n> 10, \"same\") / 189` - those lines do not exists anywhere in MAIN???\n> \n> So what is going on????\n\nFirst, I recommend that you set the `merge.conflictStyle` setting to\n`diff3` so that you get the contents of the merge base as well.  That\ncan be illustrative when you have conflicts.\n\nIt's important to note that a rebase involves replaying individual\ncommits from one branch on top of another, usually using a merge\nalgorithm.  That means that it isn't necessarily the case during a\nrebase that one side is the complete base branch, but rather one side is\nthe base branch _with all of the previous commits you've rebased on top\nof it_.\n\nSo if you have this:\n\n A - B - C - D - E - F (main)\n     \\\n      - G - H - I - J (feature)\n\nand you rebase `feature` on to `main`, you're going to replay G, H, I,\nand J (in that order) on top of F.  So it might not be that the code\nexists in `main`, but that it comes from one of those intermediate\ncommits.\n\nIn this case, the conflict should be trivial to fix up in that the code\nappears (at least to a first glance) to be logically equivalent.  I\nwould personally resolve this conflict in favour of the version with a\nlittle more whitespace, since that seems nicer to read.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"},{"id":"510980","messageId":"CAODtcdfK2s0SP1dfTbic=pPbsdui4hudeUk2RXiLNLQe35UrDQ@mail.gmail.com","threadId":"62826","inReplyTo":"Z42nq54yuWqiU4t6@tapette.crustytoothpaste.net","subject":"Re: Rebase","fromName":"Al Grant","fromEmail":"bigal.nz@gmail.com","sentAt":"2025-01-20T21:15:02Z","receivedAt":"2025-01-20T21:15:16Z","isPatch":false,"sender":{"key":"bigal.nz@gmail.com","avatar":null},"body":"Thank you for the explanation.\n\nI think in this case, what happened was I created the branch without\ndoing a git push - and so local and remote were not in sync. when I\ncreated the feature branch.\n\nThen when I went to put the feature branch on to main it complained\nabout the merge because two lines on main were different.\n\nDoes that make any sense?\n\nRegards,\n\nAl\n\nOn Mon, Jan 20, 2025 at 2:32 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> On 2025-01-19 at 20:39:13, Al Grant wrote:\n> > Yes. But I'm keen to understand how to deal with a merge conflict.\n> >\n> > My IDE is VSCode and when I run the merge I get this image:\n> >\n> > https://imgur.com/a/vynTxaj\n> >\n> > Which highlights this code:\n> >\n> > 255: <<<<<<< HEAD\n> > 256:        samples = signal.convolve(samples, [1]*189, 'same')/189\n> > 257:\n> > 258:        #for testing - log to file\n> > 259:        #self.f.write(samples.astype(np.float32).tobytes())\n> > 260:\n> > 261:=======\n> > 262:        samples = signal.convolve(samples, [1] * 10, \"same\") / 189\n> > 263:\n> > 264:        # for testing - log to file\n> > 265:        # self.f.write(samples.astype(np.float32).tobytes())\n> > 266:\n> > 267:>>>>>>> 1f893dc (Make project runnable on Linux)\n> >\n> > Now I would assume that samples = .... from ln 256 abd 262 are the\n> > differences between MAIN and FEATURE?\n> >\n> > But when I search main (at least I think its main - my IDE doesnt tell\n> > me mid rebase process) for ` samples = signal.convolve(samples,\n> > [1]*189, 'same')/189` AND `samples = signal.convolve(samples, [1] *\n> > 10, \"same\") / 189` - those lines do not exists anywhere in MAIN???\n> >\n> > So what is going on????\n>\n> First, I recommend that you set the `merge.conflictStyle` setting to\n> `diff3` so that you get the contents of the merge base as well.  That\n> can be illustrative when you have conflicts.\n>\n> It's important to note that a rebase involves replaying individual\n> commits from one branch on top of another, usually using a merge\n> algorithm.  That means that it isn't necessarily the case during a\n> rebase that one side is the complete base branch, but rather one side is\n> the base branch _with all of the previous commits you've rebased on top\n> of it_.\n>\n> So if you have this:\n>\n>  A - B - C - D - E - F (main)\n>      \\\n>       - G - H - I - J (feature)\n>\n> and you rebase `feature` on to `main`, you're going to replay G, H, I,\n> and J (in that order) on top of F.  So it might not be that the code\n> exists in `main`, but that it comes from one of those intermediate\n> commits.\n>\n> In this case, the conflict should be trivial to fix up in that the code\n> appears (at least to a first glance) to be logically equivalent.  I\n> would personally resolve this conflict in favour of the version with a\n> little more whitespace, since that seems nicer to read.\n> --\n> brian m. carlson (they/them or he/him)\n> Toronto, Ontario, CA\n\n\n\n-- \n\"Beat it punk!\"\n- Clint Eastwood\n"}]}