8

I'm commiting to git using git commit -m 'commit message', but this only has the short description. How would I add the more detailed description using git bash?

3
  • Why doesn't that work for longer messages? Commented Sep 29, 2013 at 5:45
  • I'm not saying it doesn't, but I didn't know you could have multiple options Commented Sep 29, 2013 at 5:45
  • Possible duplicate of Add line break to git commit -m from command line Commented Mar 29, 2014 at 12:53

6 Answers 6

9

Did you know you can just type git commit and it will pop open an editor for you to write your commit message in?

You can control which editor it is with some configuration. By default, Git will look at $GIT_EDITOR, then the core.editor configuration variable, then $VISUAL, and finally $EDITOR. You can look at the git-var man page for the search order, and the git-config has a little information in the core.editor section as well.

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

Comments

8

You can specify multiple -m options:

git commit -m 'foo bar' -m 'baz qux'

git log will show multiple paragraphs:

commit ...
Author: ...
Date:   ...

    foo bar

    baz qux

1 Comment

Clever, but not the best solution, as soon as you start having to use multiple lines, you're better off just opening up the commit dialog in an editor like vim.
8

How about this?

git commit -F - <<EOF
summary

This is
a multi-line
commit message.
EOF

Comments

2

You can store the long commit message in a file and specify the filename instead of the message in your command. So the command will look like-

  git commit -F <path/to/file>

Reference: https://www.kernel.org/pub/software/scm/git/docs/git-commit.html

Hope this helps!

Comments

1

From man git commit:

-m <msg>, --message=<msg>
Use the given <msg> as the commit message.
If multiple -m options are given, their values
are concatenated as separate paragraphs.

In other words, this would work:

git commit -m "Subject" -m "paragraph 1" -m "paragraph 2"

Comments

0

You take the commit message from a file if the commit message is too long

-F "file", --file="file" Take the commit message from the given file. Use - to read the message from the standard input.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.