Git - How to close the commit editor?

I am new to git and am learning PDF. I just ran the $ git commit command and opens a new editor. But I'm trying to close this new compilation editor. How to do it? I am using git for windows.

+118
git command-line version-control
Nov 05 '12 at 19:55
source share
10 answers

Save the file in the editor. If it is Emacs: CTRL X CTRL S to save, then CTRL X CTRL C exit or if it is vi :: w q

First press esc to exit edit mode. (in windows / vi)

+137
Nov 05 '12 at 19:57
source share

There were also problems. On Linux, I used Ctrl + X (and Y for confirmation), and then returned to the shell, ready to pull / push.

On Windows GIT Bash, Ctrl + X does nothing and discovers that it works just like vi / vim. Press i to enter insert mode. Enter a description at the very top, press esc to exit insert mode, then enter :x! (now the cursor is at the bottom) and press enter to save and exit.

If you print :q! instead, exit the editor without saving (and commit will be aborted)

+129
Feb 05 '15 at 11:59
source share

After recording the commit message, just press the Esc button and then write : wq or : wq! and then Type b> close the unix file.

+26
Nov 08 '17 at 6:05
source share

Better yet, configure the editor to suit your needs (gedit as an example):

 git config --global core.editor "gedit" 

You can read the current configuration as follows:

 git config core.editor 

You can also add a commit message from the command line.

 git commit -m "blablabla" 

and the editor will not be opened in the first place.

+13
05 Feb '15 at 12:06
source share

As an alternative to save and complete, you can use the git-commit-commit function git-commit-commit , which is bound to Cc Cc by default. It will save the file and close it. Subsequently, you still have to close emacs with Cx Cc , as mentioned earlier. I'm currently trying to figure out how to get emacs to exit automatically.

+1
Jun 15 '15 at 9:04 on
source share

After the git commit command, you entered the editor, so first press i then start typing. After confirming your message, press Ctrl + c then :wq

+1
Apr 26 '19 at 18:16
source share

I had this problem that I did not like, and I could not solve it. I change the "in comments for" and it works.

I hope this helps someone!

0
Mar 22 '18 at 22:10
source share

Alternatives to Nano (can make your life easier):

On Windows, use notepad. At the command prompt, type:

git config core.editor notepad

On Ubuntu / Linux, use a text editor (gedit). In the terminal window, enter:

git config core.editor gedit

0
Feb 02 '19 at 15:09
source share

Not sure if the key combination that leads you to the> prompt, but this is not the bash prompt that I know. I usually get this by accident. Ctrl + C (or D) brings me back to the $ prompt.

0
03 Feb '19 at 17:54
source share

Note that if you use Sublime as a commit editor, you need the -n -w flags , otherwise git will think that your commit message is empty and breaks.

0
May 14 '19 at 1:29
source share



All Articles