I've read in many places (including this question Git workflow and rebase vs merge questions) that it's a good practice to do a rebase of main into local branch before merging this branch to main. but I can't understand why should I rebase main, why not just merge it to my branch?
Asked
Active
Viewed 136 times
0
-
While many people *like* rebase-oriented workflows, there's no *requirement* for them. Whether to use them is a matter of opinion. (Analogy: I may think pistachio ice cream is awful, but that does not mean you should not eat it if you like it.) – torek Aug 02 '21 at 09:59
-
Hey, git merge creates an extra commit, however git rebase makes your history linear which would later help you to debug your bugs through tools such as git-bisect. Git rebase however messes with your history and may be bad for large number of commits. You can refer to this answer: https://stackoverflow.com/a/36587353/12590748 – Anurag Shukla Aug 02 '21 at 10:06
-
Also, I'd argue you want to rebase `local` onto `main`, not the other way round. History `main` should never be rewritten. – knittl Oct 23 '22 at 20:22