niceEli.tech

Merge Commits Vs Squash & Merge

By Eli Cardoso

in Main

Merging a git commit is a important task that many maintainers do, however there is multiple ways to do it, with many positives and negatives.

Computer With Code On It

Merge Commits are great as it shows the entire commit history of a branch (which you may or may not want) it also shows a handy merge commit in the tree that is authored by the MERGER, this is important for later.

Merge Commit Example Merge Commit Example

Squash and Merge is my personal favorite as it condenses the entire pull into 1 commit, allowing for conventional commits to be used in a neat way. Squash and Merge also does not create a second commit showcasing the merge, only having that one commit (with a name either auto generated or created by the merger).

Squash and Merge Example (This wasn’t 2 commits in the pr but there could of been and would of shown the same) Squash and Merge Example (This wasn’t 2 commits in the pr but there could of been and would of shown the same)

Merge Commits and Squash and Merge both have their benefits (i prefer the latter) and its usually up to opinion and repository rules on what gets used.

Merge Commits Vs Squash & Merge