0

I am using git CMD and I am able to do the commit if I do

git commit -m "some message"

However, if I forget to add the -m it presents me with a message saying to create the message. I know I am suppose to create a "title", leave a blank line, then create "description". After I do that I am not sure how to push the commit through. I press enter on my keyboard, but it just creates more lines. Is there a command?

LearnSomeMore
  • 440
  • 4
  • 12
  • http://stackoverflow.com/a/11828573/1594980 provided it's vim. "I've been using Vim for about 2 years now, mostly because I can't figure out how to exit it." ;) – Jiri Kremser Apr 06 '16 at 23:53
  • Can you check what editor is set up with Git? I think you can use `git config --global core.editor` check what editor is configured with Git. – Rashmirathi Apr 07 '16 at 00:21

2 Answers2

3

If you do not specify the -m Option, git will open an editor to type your commit message. Simply type you message, write the file, and close the editor.

Git determines the editor to lauch either by the the core.editor config option of git or by the EDITOR environment variable of your system.

If you did not explicitly configure an editor, chances are good that it will launch a vim editor. To write your file and leave it you can use ESC:wqEnter.

If you want to give vim a try, you can learn more about its usage by running vimtutor. If you don't like vim, simply configure a different editor.

michas
  • 25,361
  • 15
  • 76
  • 121
1

You are in a vi editor or a nano.

In order to save and exit from vi you need to do this:

To save the changes: ESC + :wq
To discard the changes: ESC + :q!

If you are using nano you will see a "menu" like on the button of your screen with caption about each key what it does.

(Look on the button of the screenshot how to exit)

enter image description here

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • In vi/vim, `:x` (or `ZZ`, two uppercase `Z`s, which invokes `:x` from within the visual mode) is safer than `:wq` since in traditional versions of vi the latter will quit the editor even if the write fails (!) (certainly a bug). It's also a bit shorter, so is thus a good habit to get into for two reasons. – torek Apr 07 '16 at 01:02