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?)
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With