Agree if you want a linear or non-linear commit history. There are pros and cons to both approaches:
- Pro linear: Avoid messy git history, use linear history
- Con linear: Why you should stop using Git rebase
Merging topic
into main
A---B---C topic
/ \
D---E---F---G---H main
git fetch origin
git checkout main
git merge topic
Before merging topic
into main
, we rebase topic
with the main
branch:
A---B---C topic
/ \
D---E---F-----------G---H main
git checkout main
git pull
git checkout topic
git rebase origin/main
Create a PR topic --> main in Azure DevOps and approve using the squash merge option
Squash merging is a merge option that allows you to condense the Git history of topic branches when you complete a pull request. Instead of adding each commit on topic
to the history of main
, a squash merge takes all the file changes and adds them to a single new commit on main
.
A---B---C topic
/
D---E---F-----------G---H main
Create a PR topic --> main in Azure DevOps and approve using the squash merge option