I am not able to write git commit message. I want to write
Fixes issue #10 - one line description of changes
I am not able to type anything inside git console. It does not take any keystrokes that I type in.
-
2Are you familiar with vim? It's the default console editor. Press I to go into insert mode and ESC to go into 'normal' mode where you can move around the text. – Dan Schnau Dec 28 '17 at 12:28
-
@DanSchnau No I am not familiar with vim I am new to git. – Ice fire Dec 28 '17 at 12:29
-
1Check this to change what editor git useshttps://stackoverflow.com/questions/2596805/how-do-i-make-git-use-the-editor-of-my-choice-for-commits#2596835 – Dan Schnau Dec 28 '17 at 12:29
3 Answers
This editor seems to be a variant of vim. Initially you are not in edit mode, to be able to input stuff press the i
key to enter input mode. This allows you to type whatever you want.
After entering your message you need to hit esc
to exit input mode. Then you need to issue a command to save and close, which can be done by typing :wq
. :
means the start of the command. w
is used for saving (write) and the q
let's you quit the editor.
Alternatively it is also possible to write a commit message without using this editor as the other answer explains.

- 873
- 8
- 19
-
Thanks got it and if I want to exit commit message I can use `:x!` am I right ? – Ice fire Dec 28 '17 at 12:34
-
2For exiting you can just use ```:q```, the exclamation mark should only be used when wanting to force your command. In the case of the quit command that could for example be quitting without saving (thus discarding your changes). If you want to exit the editor after saving your commit message you can just exit normally, if you want to discard your commit message (and commit) you will have to force it. This however will require you to restart the entire committing process. – yarwest Dec 28 '17 at 12:45
You can do your commit with -m
parameter like git commit -m "Fixes issue #10 - one line description of changes"
and it will add your commit message.

- 1,497
- 13
- 21
-
but when I do `git commit` how can I type in the message after `git commit`. – Ice fire Dec 28 '17 at 12:28
-
When you commit with git, it will use vim to prompt you to type in your commit message. Vim is a popular editing program but it does take a bit of getting used to. You can either search for a quick vim crash course or change the default editor: How do I make Git use the editor of my choice for commits?

- 1,505
- 14
- 17