I want to go to the git commit command prompt to add a multi-line message command line in windows. I am able to add commit in a single line using command but I want to add multiple lines of message.
Asked
Active
Viewed 116 times
-2
-
What have you set as your git editor? – matt Aug 09 '21 at 14:33
-
I havent set it to anything. I want to add commit message to individual files – vibha_v Aug 09 '21 at 14:42
-
So you'd like to use `git commit -m
` where `msg` spans multiple lines? – Brad Solomon Aug 09 '21 at 14:43 -
@matt it seems like the question revolves around git not kicking off to an editor, but rather passing multi-line `-m` value on the command line. – Brad Solomon Aug 09 '21 at 14:45
-
But if the editor is vim you're still on the command line. – matt Aug 09 '21 at 14:53
1 Answers
1
If you want to set a multiline message using -m
, just pass in a multiline message as the value of that option. E.g., I can write (assuming a bash
shell):
$ git commit -m $'This is\n\nThis is only a test'
And I get:
commit 676ffa32c7adf88e4abafdacf9ba55f9526cd454 (HEAD -> master)
Author: Lars Kellogg-Stedman <lars@oddbit.com>
Date: Mon Aug 9 10:52:49 2021 -0400
This is a test
This is only a test
I could also write instead (assuming any posix-y shell):
$ git commit -m 'This is a test
This is only a test'
That results in the same thing.
If you're working with Powershell instead, you can probably do something similar.

larsks
- 277,717
- 41
- 399
- 399