-2

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.

5
  • What have you set as your git editor? Commented Aug 9, 2021 at 14:33
  • I havent set it to anything. I want to add commit message to individual files Commented Aug 9, 2021 at 14:42
  • So you'd like to use git commit -m <msg> where msg spans multiple lines? Commented Aug 9, 2021 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. Commented Aug 9, 2021 at 14:45
  • But if the editor is vim you're still on the command line. Commented Aug 9, 2021 at 14:53

1 Answer 1

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 <[email protected]>
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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.