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.

3
  • Save it and exit from editor Commented Jul 5, 2014 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]: stackoverflow.com/a/9171451/4712847 Commented May 7, 2015 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. Commented Nov 16, 2017 at 15:21

5 Answers 5

16

Save the file and exit your editor.

Sign up to request clarification or add additional context in comments.

2 Comments

Some more detail would have been nice.
Without knowing what editor you're using, it's a bit hard to say any more.
15

try this:

git add file-name  
git commit -m "here goes my awesome commit message"  
git push  

1 Comment

It's generally bad practice to type your commit message on the command line, mostly because it discourages good commit message structure and habits.
10

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.

1 Comment

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.
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.

Comments

1

To save your commit message and exit your text editor, follow these steps:

  1. Type your commit message as usual.

  2. Press ESC to exit insert mode.

  3. Type :wq (which stands for write and quit) and press Enter.

2 Comments

This assumes the configured editor is vi/vim.
Yes, this is for vim. And this whole solution is used for Git Bash and it uses vim editor. I hope this helps you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.