git automatically generates your preferred $EDITOR to request a commit message when you run git commit . So it can be as simple as leaving -m with your git commit command
If git starts the wrong editor or doesn't start the editor, try setting the EDITOR environment EDITOR to your preferred editor:
export EDITOR=/usr/bin/vim
Or, to change the editor used by git, you can set core.editor
git config --global core.editor /usr/bin/vim
Using an editor to compose a commit message in this way has several additional advantages. git fills out the file you are editing, with the sum of the files that were changed in the commit, which should help you write the best commit message. In addition, vim (and other editors) support basic syntax highlighting for this type of file, which makes it even easier.
source share