如何在git中添加长描述

时间:2013-09-29 05:41:43

标签: git

我正在使用git commit -m 'commit message'进行git,但这只是简短描述。我如何使用git bash添加更详细的描述?

6 个答案:

答案 0 :(得分:4)

这个怎么样?

git commit -F - <<EOF
summary

This is
a multi-line
commit message.
EOF

答案 1 :(得分:4)

您知道吗,您只需键入git commit,它就会弹出一个编辑器 你在?

中写下你的提交信息

您可以使用某些配置控制它所使用的编辑器。默认情况下,Git 然后会查看$GIT_EDITOR,然后是core.editor配置变量 $VISUAL,最后是$EDITOR。你可以看一下 搜索顺序的git-var手册页, 并且git-config有一点点 core.editor部分中的信息。

答案 2 :(得分:3)

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

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

git log会显示多个段落:

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

    foo bar

    baz qux

答案 3 :(得分:1)

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

  git commit -F <path/to/file>

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

希望这有帮助!

答案 4 :(得分: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"

答案 5 :(得分:0)

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

-F“file”, - file =“file”            从给定文件中获取提交消息。  使用 - 阅读            来自标准输入的消息。