Below are some options/strategies for merging Pull Requests (PRs) into a project's repository. Typically this will be into the project's master branch, but may also be a dev or feature branch. Please also note that a single project/repository may decide to use a variety of strategies based on the situation and context. For example "squash merge" PRs into a dev branch, and to a no-ff merge from dev to master. 

NOTE: this document is based off a discussion about merge options from June 3, 2020 (original Google Doc).

Merge --no-ff

Command: git merge <branch name> --no-ff --log 

See: git-merge

This uses the default git merge strategy and forces a merge commit which will contain a log of the individual commits. --no-ff  forces a merge commit, preventing a fast-forward commit. --log adds a log of the individual commit messages to the merge commit.


Examples of when to use

Squash Merge

Command: git merge --squash --log 

See: git-merge

Performs a merge by combining all of the commits to be merged into a single new commit. The merge commit will include a log of the individual commit logs from the squashed commits.

Examples of when to use

Rebase before merge

Command: git rebase master

See: git-rebase, Git Branching - Rebasing

In this case the onus is on the contributor to do the work; however, the project may require that a contributor rebase their work as the final step before a PR is merged into the repository. Rebasing allows for a contributor to clean up the presentation of commits, including potentially squashing commits together. 

NOTE: If the desire is only to combine a continuous sequence of commits  git commit --amend  or a form of git reset  may be used instead.

Examples of when to use