For your question: How to write multi-line shell commands that let you go back to the first line
Instead of hitting Enter at the end of the first line, use Ctrl+V Ctrl+J. That'll insert a newline without entering the command to bash. No new prompt (like
>) will be printed, because to bash, it's still the same entry. If you had done that, you would have been able to go back to the first line with Ctrl+A when using the default emacs keybindings or
^ when using the vi keybindings.
Here's an example with bash using the default emacs bindings:
If you use zsh instead of bash, then you can use the Up/Down keys, or Ctrl+P/Ctrl+N with default emacs keybindings, or
k with vi keybindings to move between the lines of the single prompt entry.
If you use zsh with vi keybindings, you can also use
O in normal mode to create new lines below or above the current one in the same prompt entry. Those are the keybindings that I normally use in zsh:
For your situation: How to fix the start of your git message from the end of the command
-e at the end of the command, and git will take you to the editor with the contents of the
Here's an example of what you could've done in your particular situation: