1

I typed the following:

git commit

I did not specify a message and now I have this screen:

enter image description here

I have tried typing or doing the following:

  1. "testing"
  2. q
  3. hitting the ESC key
  4. git commit "testing"

Nothing seems to work, how can I get past the screen without closing Git CMD?

  • Use :- git commit -m "". instead of git commit – Pratap Alok Raj May 19 '21 at 02:09
  • Or if you are stuck at this screen, after you write git commit and press enter, please press "i" key from your keyboard, write your message and then press ESC and write ":wq" – Pratap Alok Raj May 19 '21 at 02:11
  • @akok raj: But if I use "git commit" by mistake, I get the screen above, how can I move forward from that screen? – Chicken Sandwich No Pickles May 19 '21 at 02:11
  • can you try the second thing I mentioned above, by pressing "i" and moving forward – Pratap Alok Raj May 19 '21 at 02:15
  • I did that, but it seems there was a step or 2 missing. I followed it exactly in the answer and it worked. – Chicken Sandwich No Pickles May 19 '21 at 02:24
  • 3
    You're in your favorite editor! Or rather, you're in the editor you told Git is your favorite. If you didn't tell Git, it took a guess based on your system. If its guess is wrong, and you like a different editor, be sure to tell Git which one: `git config --global core.editor ` where you fill in the `` part. – torek May 19 '21 at 02:41
  • 1
    Also worth noting: some editors (e.g., Atom, some varieties of Emacs) use a system where there's one instance of the editor running most of the time, and invoking the editor on a file detects the already-running one instead of actually running the editor. Git gets confused if the command it runs exits immediately, rather than waiting for the file to be edited. If your favorite editor is one of these kinds, find out how to make the command that Git runs, wait until the file is written out. (That's somewhat commonly a `-w` or `--wait` option.) – torek May 19 '21 at 02:43
  • Just to add to the 2.3m views of *that* question : [How do I exit the vim editor ?](https://stackoverflow.com/questions/11828270/how-do-i-exit-the-vim-editor) – LeGEC May 19 '21 at 09:02

3 Answers3

2

The editor that actually pops up is Vim. To type, press the i key. To exit typing mode, hit the escape key. Navigate with your arrow keys. For example, to enter a commit message, you would type i, then you would hit enter to go onto a new line. Then, type out your message. After that, hit the escape key. Then, type the : key and then wq after that to write and quit it. The full thing should be :wq. This will now get you back to the normal terminal!

ShrubtheBub
  • 126
  • 2
  • 5
1

Also you can use git commit --amend to modify the last commit

mhered
  • 184
  • 1
  • 1
  • 8
1

By default, git will use vi as a text editor, and @ShrubtheBub's answer is 100% correct to guide you into your first steps with vi.


You may however want git to open a more friendly text editor (say Notepad++ or VSCode ?) when git asks you to edit text.

There is a configuration parameter for that : core.editor

You can read this guide from the official git book, for example :

  • here is a line to say "use notepad++" :
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
  • to use VSCode instead, type :
git config --global core.editor "code --wait"

(taken from the vscode documentation)

LeGEC
  • 46,477
  • 5
  • 57
  • 104