This page looks best with JavaScript enabled

The Difference Between GitHub's Three Code Merge Methods

 ·  ☕ 1 min read

1. Create a merge commit

PR commit log:

1
2
commit c1
commit c2

Integration branch commit log:

1
2
3
commit PR #NUM
commit c2
commit c1

Create a merge commit carries every commit in the PR over to the integration branch intact, and adds one PR commit entry on top.

2. Squash and merge

PR commit log:

1
2
commit s1
commit s2

Integration branch commit log:

1
commit PR #NUM

After a Squash and merge, the integration branch gains only a single commit entry. It looks clean, and it is friendly to PRs with many commits, so it is worth recommending. Both the PR title and description can be viewed directly on the integration branch.

3. Rebase and merge

PR commit log:

1
2
commit r1
commit r2

Integration branch commit log:

1
2
commit r2
commit r1

Rebase and merge carries every commit in the PR over to the integration branch intact. Also, if the development branch has not been rebased, continuing to push commits for the PR record looks like this:

1
2
3
4
commit r1
commit r2
commit new1
commit new2

But code that has already been merged will not be merged again; this only affects how the PR commit log looks.


WeChat Official Account
WRITTEN BY
WeChat Official Account