Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I exit my git commit message? I'm NOT in the VIM, I used the " commit -m " command

I was trying to commit a message and I accidentally made a typo:

'git commit -m 'Deleted old Basic Syntax chapter README'

Now i'm stuck in the terminal, and all it shows is:

> 
>
>
>
>asdfasdfad
>
>asd
>

How do I exit out of this, but still keep my commit message? I'm fine with having to re-commit, but I dont want to have to exit the terminal because I'm sitting on a few commits that I don't want to lose. (If i'll lose them at all?)

like image 788
Hunter Avatar asked Oct 07 '14 05:10

Hunter


People also ask

How do I leave a git commit message?

Typing :wq and pressing enter should do it, i.e. save the commit message and exit. : enters the command mode, w is for "write" (save) and q is for "quit". You may need to hit escape before :wq to exit the insert mode ( vi is a mode based editor). If you want to exit without saving hit escape, :q! and enter.

How do I close a git commit?

If your Git default text editor is “Notepad++”, then after adding the commit message in the editor, press “CTRL + S” to save changes. After that, hit the “Esc” key to quit the editor. However, if you are using any other text editor such as “vi” editor, then type the “:wq” command and press the “Enter” key to close it.

How do I stop a commit message in terminal?

On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit.


1 Answers

You won't lose commits by closing the terminal.

ctrl+c will exit the prompt >

What happened was you opened up a string with the odd number of ' characters.
Bash expects more input for your string, and allows you to enter it after the > prompt.

Try typing ' and hit return, you will get the same thing. If you close the string by typing '`' again, you will be back to your normal bash prompt.

like image 162
Travis Avatar answered Sep 18 '22 14:09

Travis