How to Close the Git Commit Editor on Windows
In this article, we will discuss how we can exit the Git commit editor. It can be a bit tricky, especially if you are new to Git bash.
Let us see how we can exit the editor on Windows.
Close the Git Commit Editor on Windows
We will look at the typical commit flow on Git to make it easier to understand. From the example below, we can see the several untracked files we have by running the git status
command.
pc@JOHN MINGW64 ~/Documents/GitHub/Delftscopetech (main)
$ git status
On branch main
Your branch is ahead of 'origin/main' by 3 commits.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore~
Example Code 2
Example Code 2.php
Example Code 3.php
Example code 1.php
downloadpdf.php
htmllinkpdf.html
nothing added to commit but untracked files present (use "git add" to track)
Let us add the downloadpdf.php
file and commit the changes. We run the code below to add:
$ git add downloadpdf.php
To commit, we run the command below:
$ git commit
Upon running the git commit
command, the commit editor will pop up, as shown below:
Follow these steps to save your commit and exit the editor.
-
A newly opened editor is usually in
normal
mode. Usei
to switch to the insert mode. -
On the first line, write your commit message and hit
esc
to switch back tonormal
mode. -
Type
:wq
to save and exit the editor. -
Hit
enter
to return to the normal terminal window.
It is that simple to exit the editor on Windows. This method works for vi
and vim
editors.
For those using the Emacs editor, use Ctrl+X Ctrl+S to save and Ctrl+X Ctrl+C to quit the editor.
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.
LinkedIn