Git – Useful git commit messages for merged branches

branchinggit

As a follow-up to this question:

If I'm working on a team by myself, I can maintain useful commit messages when merging branches by squashing all the commits to a single diff and then merging that diff. That way I can easily see what changes were introduced in the branch, and I have a single summary describing the feature/change/whatever that was accomplished in that branch when browsing the master branch.

My question now is, how can I accomplish this when working with a team? In that situation, the branches will be pushed to a remote repository, meaning that I can't squash all the commits in the branch down to a single commit. If the branch is public, can I still have a single useful merge commit in the master branch? (By "useful" I mean that the commit in the master line tells me (1) a useful summary of what was done in the branch and (2) diffs of the same.)

Best Answer

This turns out to be pretty simple to do, using some git merge flags I wasn't familiar with.

  • The -e flag allows you to edit the message that occurs when you merge.
  • The --log flag appends the one-line commit message from all commits in the branch to be merged to the commit message, making it easier to remember what you've done.
Related Topic