When you create a new commit, git fires up a text editor and writes some stuff into it.
Using this text editor, the intention is for you to write the commit message that will be associated with your feshly created commit.
After you have finished doing so, save and exit the text editor. Git will use what you've written as the commit message.
The commit message has a particular structure, described as follows:
The first line of the commit message is used as the message header (or title). The preffered length of the commit header is less than 40 characters, as this is the number of characters that github displays on the Commits tab of a given repository before truncating it, which some people find irritating.
When composing the header, using a capitalized, present tense verb for the first word is common practice, though not at all required.
One newline delineates the header and body of the message.
The body can consist whatever you like. An overview of the changes introduced by your commit is reasonable. Some third party applications use info included the body of commit messages to set off various kinds of hooks (I'm thinking Gerrit and Pivotal Tracker, to name two).
Here's a short and sweet example. A leading #
denotes a comment.
Gitignore index.pyc
Ignore gunicorn generated binary file
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch dev
# Your branch is ahead of 'origin/dev' by 10 commits.
# (use "git push" to publish your local commits)
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: .gitignore
#
Here one Mr. Torvalds opines on what makes a good commit.
And here Tpope does likewise.
As stated in several other answers, changing the default editor is a one-liner on the command line.
For my preference:
git config --global core.editor "vim"