0

I did a git add for a codeshare10-18.txt I wanted to push into my own respository. I then did git commit codeshare10-18.txt, and since I forgot to add a message, I got a warning with this at the end:

"C:/Users/Nicolas/Desktop/workshop/neobis001.github.io/.git/.COMMIT_EDITMSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

I didn't know what to do, so I pressed E because I thought I could add a message that way. I got this colored screen in return:

enter image description here

I tried typing a message like "Added a txt". The "A" got cut off, and when I tried to press Enter, it just made a newline in cmd to type more stuff. What is this window, and how do I get out of this window without clicking the X button? I tried Ctrl + C, Esc, and "exit" plus Enter, but none of them worked. I know next time I should include a message, but I'd still like to know how to get out of here via a console command.

DragonautX
  • 860
  • 1
  • 12
  • 22

1 Answers1

6

That is the vim text editor.

When it opens up, you can to the following:

  • Press i to enter insert mode
  • Type in your commit message
  • press ESC to exit insert mode
  • press ZZ to save and exit

Alternatively, for the last step you can type in :wqENTER (ZZ is just a shortcut to that).

Cristian Lupascu
  • 39,078
  • 16
  • 100
  • 137
  • I tried "ZZ" but I get `E45: 'readonly' option is set (add ! to override)`. I tried "!", but nothing happened. I also tried `wq` then Enter, but I get the same message back. Do you know what to do from here? – DragonautX Oct 19 '16 at 07:28
  • 1
    @DragonautX You can save&exit a readonly file using `:wq!` as a last step. But perhaps it's best to just remove the `C:/Users/Nicolas/Desktop/workshop/neobis001.github.io/.git/.COMMIT_EDITMSG.swp` file and then commit the way you usually do. – Cristian Lupascu Oct 19 '16 at 07:31
  • Thanks. I'll google more about the vim text editor, didn't know what it was called before. – DragonautX Oct 19 '16 at 07:33
  • 1
    @DragonautX: VI and VIM are quite famous for various reasons, one of them is a user not accustomed to VIM getting stuck in it. There's even a joke about using VIM as a secure screen saver, because noone knows how to exit from it.. – quetzalcoatl Oct 19 '16 at 08:23
  • @quetzalcoatl Haha nice one. If I ever have to do a lab at my university with git, I'll make sure to tell that to my partner. – DragonautX Oct 19 '16 at 08:28
  • 1
    there's also this joke: https://github.com/thepracticaldev/orly-full-res/blob/master/exitingvim-big.png :) – Cristian Lupascu Oct 19 '16 at 08:51