From time to time I need to clean-up a Git repository before making it accessible to others. One step is to fix unspecific commit messages and add version tags.
Caution: The following modification should not be done if the repository is already shared with others.
Most of the job can be done with the interactive rebase command, but if you want to also clean-up the root commit message you have to invest a bit more work. This is a modified/adapted solution from a thread found on stack overflow.
First fetch the SHA1 checksum of the first/root commit:
git rev-list --max-parents=0 HEAD
Checkout that commit, ignore the warning message:
git checkout <root-sha1>
Now you can use the amend feature of the git commit command to fix the (from this point of view most recent) root commit:
git commit --amend
Now you can add the remaining commits to the modified root commit. By making it interactive you can either meld multiple commits (squash) or just edit their commit messages (reword):
git rebase -i --onto HEAD HEAD master