Exit the Commit Message Editor

John Wachira Sep 28, 2022 Git Git Commit
Exit the Commit Message Editor

This article outlines the steps to exit the commit message editor in Git. When merging or making a commit in Git, the console will prompt you to give a commit message giving a brief description of the new commit.

Git opens your default text editor, where you are supposed to give the commit message. Navigating through the text editor can be confusing, especially if you are new to the Git version control.

By the end of this article, you will have the necessary knowledge to navigate through the Git text editor.

Exit the Commit Message Editor in Git

For easier context, we will try to commit some changes for Git to prompt us with the text editor.

commit message

First we will press i for insert to give our commit a message. Once done, press Esc for escape.

Press :+w+q for write and quick (:wq). Press Enter to finish the process. It is as simple as that.

Git also states that if you fail to provide a commit message, it will abort the merge or commit. If you want to exit without merging, leave the message blank and use the above keyboard combo to exit.

Note that the combination above only works for the vim editor. If you are using the nano editor, use the combination shown below.

nano editor

The ^ is simply the Ctrl key. Hence, to exit the Nano editor you should use Ctrl+X.

When making a commit in Git, use the -m flag to include a commit message, as shown below.

$ git commit -m "Commit Message"

This will save you the pain of navigating through the text editor.

Author: John Wachira
John Wachira avatar John Wachira avatar

John is a Git and PowerShell geek. He uses his expertise in the version control system to help businesses manage their source code. According to him, Shell scripting is the number one choice for automating the management of systems.


Related Article - Git Commit

  • Get Current Commit in Git
  • Git List Commits
  • Git Add and Git Commit in One Command
  • git add, git commit, and git push in One Command
  • Commit Current Changes to a Different Branch in Git