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 j
/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
/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
Just add -e
at the end of the command, and git will take you to the editor with the contents of the -m
argument(s).
Here's an example of what you could've done in your particular situation:

-m <message>
, and git will open a text editor and allow you to type your message there, committing when you save and exit. The editor it uses is theGITEDITOR
env var, which can be set in a.bashrc
. I setexport GITEDITOR=nvim
because it is easier than trying to deal with bash's multi-line strings.git commit --amend