• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Draft / Git Commit Message Editor

Git Commit Message Editor

Last updated on January 14, 2020 by Sal Ferrarello

The default editor used by Git, is the default editor setup for your user in your Bash session. Most often, Vim is the default editor. While I’m a big fan of Vim, it does take some time to master.

I've been using Vim for about 2 years now, mostly because I can't figure out how to exit it.

— I Am Devloper (@iamdevloper) February 17, 2014

Nano as an Alternative to Vim

In my experience, many users find Nano easier to use. You can tell your system to use Nano as your default editor when writing Git commit messages by typing

git config --global core.editor "nano"

You’ll only need to run this line once. It adds a line to your ~/.gitconfig file, so Git uses Nano for all editing.

Other Alternatives

You can set Git to use any editor on your system, including graphical interface editors like Visual Studio Code. I personally prefer not to do this because I like my Git commit message editor in the window where I’m typing my Git commands.

Visual Studio Code

We first must make a modification so we can run Visual Studio Code from the command line.

  1. Run Visual Studio Code
  2. In the menu click View > Command Palette
  3. In the box that pops up, type shell command
  4. Choose `Shell Command: Install ‘code’ command in PATH

Screenshot of selecting "Shell Command: Install ‘code’ command in PATH" in Visual Studio Code.

Now when you type code on the command line, Visual Studio Code will run.

Now that we can run Visual Studio Code from the command line with code, we can set it as the editor for Git.

git config --global core.editor "code --wait"   

MacVim

git config --global core.editor "mvim -f"

Atom

git config --global core.editor "atom --wait"

Sublime Text Editor

git config --global core.editor "subl -n -w"

I Don’t Need Any Editor

At this point you may be saying, “I don’t need any editor. I use the - m parameter with git commit to enter my commit message as part of the command. e.g.

git commit -m 'Fix Spacebar causing CPU to overheat'

Please Don’t Do This

Please do not use the one line version of commit messages (made popular by the parameter -m). Well crafted commit messages are invaluable. For more information on writing valuable commit messages, see How to Write a Git Commit Message.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Computing, Dev Tips, Draft, Programming, Recommendations, Solution Tagged With: Git, gitconfig, nano, Visual Studio Code

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in