27

After I type in git commit -a a text editor pops up and I type in my comment. What buttons do I have to press after typing in the comment, to get it to move to the next stage of actually committing?

I'm using mysysGit on Windows with the default setup.

Curyous
  • 8,716
  • 15
  • 58
  • 83
  • Save it and exit from editor – 0xAX Jul 05 '14 at 10:04
  • 2
    This guy explained it well [In vim, you can press i to start entering text and save by pressing esc and :wq and enter, this will commit with the message you typed.][1] [1]: http://stackoverflow.com/a/9171451/4712847 – LouieT May 07 '15 at 20:44
  • 2
    Git in Windows brings up a default editor from cmd (command line), I think part of the problem is that we don't know what editor those sneaky git-programmers decided to impose on us. The text is colorful and we see some comments but there's no title-bar or any other indication of how to proceed. – Jason K. Nov 16 '17 at 15:21

4 Answers4

15

try this:

git add file-name  
git commit -m "here goes my awesome commit message"  
git push  
zengr
  • 38,346
  • 37
  • 130
  • 192
  • 4
    It's generally bad practice to type your commit message on the command line, mostly because it discourages good commit message structure and habits. – void.pointer Dec 01 '14 at 15:20
14

Save the file and exit your editor.

Nicholas Riley
  • 43,532
  • 6
  • 101
  • 124
7

Depends on the text editor you are using. Git chooses the editor specified in the environment variable "EDITOR." On Linux systems this is usually either Vi or Nano. Figure out which it is and then refer to the documentation for the appropriate editor.

Max E.
  • 1,837
  • 13
  • 15
  • 11
    MysysGit on Windows uses VIM, so according to the VIM documentation, press Esc to leave edit mode, then ZZ to save changes if there any and exit. – Curyous Feb 20 '11 at 00:06
4

A git commit always requires a comment. You can give one like this git commit -m "my comment". If you do not provide a comment here, then a text editor pops up to force you to give a comment.

Sometimes, you may actually need the editor to put in the commit message. This generally is required when you want to give a more detailed description of the commit along with the summary (write the summary followed by a blank line followed by the description).

This is an extract from git help commit.

Though not required, it's a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. Tools that turn commits into email, for example, use the first line on the Subject: line and the rest of the commit in the body.

EDIT:

And after you type text in your text editor, just save and close it. If you try to do it without providing any comment, the commit will fail.

Hunsu
  • 3,281
  • 7
  • 29
  • 64
Sailesh
  • 25,517
  • 4
  • 34
  • 47