How to merge main into a branch in Git (and when to rebase instead)
Blog post from Mergify
Julien Danjou’s blog post explains the process and considerations involved in updating a feature branch that has fallen behind the main branch in Git, focusing on the choice between using merge and rebase commands. The article describes the technical steps for both merging and rebasing, highlighting how each method affects the commit history and potential conflicts that may arise. While merging integrates the main branch into the feature branch with a new merge commit, preserving the original history, rebasing rewrites the branch's history by applying new main commits followed by the original feature branch commits, resulting in a linear history. The choice between these methods should be guided by team policies on branch history and the potential for conflicts, especially if branches are shared. Additionally, the post suggests the use of a merge queue to handle the integration of multiple pull requests efficiently, ensuring that the branch being reviewed is the one that ultimately gets merged, thus avoiding frequent re-syncs and unexpected CI failures.