6

我承诺使用 git git commit -m 'commit message',但这只有简短的描述。如何使用 git bash 添加更详细的描述?

4

6 回答 6

6

你知道你可以直接输入git commit,它会弹出一个编辑器让你写下你的提交信息吗?

您可以通过一些配置控制它是哪个编辑器。默认情况下,Git 会查看$GIT_EDITOR,然后是core.editor配置变量,然后 $VISUAL是 ,最后是$EDITOR。您可以查看 git-var搜索顺序的手册页,git-config该部分中也有一些信息core.editor

于 2013-09-29T14:04:41.117 回答
5

您可以指定多个-m选项:

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

git log将显示多个段落:

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

    foo bar

    baz qux
于 2013-09-29T05:44:40.020 回答
5

这个怎么样?

git commit -F - <<EOF
summary

This is
a multi-line
commit message.
EOF
于 2013-09-29T05:58:03.553 回答
1

您可以将长提交消息存储在文件中,并在命令中指定文件名而不是消息。所以命令看起来像 -

  git commit -F <path/to/file>

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

希望这可以帮助!

于 2013-09-29T05:48:08.773 回答
0

来自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.

换句话说,这将起作用:

git commit -m "Subject" -m "paragraph 1" -m "paragraph 2"
于 2013-09-29T05:46:47.847 回答
0

如果提交消息太长,则从文件中获取提交消息

-F "file", --file="file" 从给定文件中获取提交信息。使用 - 从标准输入读取消息。

于 2013-09-29T05:48:33.627 回答