There are some rules that are best to follow when merging a pull request.
When merging a pull request, GitHub offers 3 options:
Create a merge commitSquash and mergeRebase and merge
We should use each of them depending of the situation:
- If PR has only one commit and commit explains well what was done use
Rebase and merge - If PR has only one commit but commit does not explain exactly what was done use
Squash and mergeand add commit name that will explain more exactly what was done - If PR has more commits but they are intermediary (ex: fix style, add object, remove test ) also use
Squash and mergeand add a commit name that will group all commits in one - If PR has more commits but every commit has an explicit title what has been done, each commit is a single unit, then use
Create a merge commitso each commit will be visible in default branch
If you want to read more about how to write correct commit messages, follow the link https://conventionalcommits.org
Top comments (3)
Wow. This is a really good strategy. Very nice tip, thanks! Squashing bad commits and commit messages sounds great as sometimes the source history for a branch is not useful anyway.
Usually my team aims for good commits like in your last point, but it doesn't always happen.
Check out this conventionalcommits.org
Thanks very much. That's already what I use ;). Highly recommended for everyone.