Git merge commit with no fast forward

When working in open source, it is quite common that I want to either manually merge in a pull request or refer to a Github issue when merging in one of my own branches. If you do a merge and there are no merge conflicts then Git will not create a commit. It does a fast-forward merge as this is the desired behaviour most of the time.

To create a merge commit when merge in a branch, I use this command:

git merge branchname --no-ff -m "Merge pull request #999 from fork/branch"

The –no-ff switch means no fast-forward while merging. There is some Github functionality in the commit message. Using # and the issue or pull request number will create an automatic link to this commit in the issue or pull request.

Github PR
Commit reference as seen in a Github Pull Request