简体   繁体   English

有关Git的扩展描述文本

[英]Extended description text on Git

I want commit with message and Extended description text to Bitbucket server. 我想将消息和扩展描述文本提交到Bitbucket服务器。 It exists on Git-cola software and I need the command line of it. 它存在于Git-cola软件中,我需要它的命令行。 I am using ubuntu and I need terminal command for Extended description 我正在使用ubuntu,并且需要终端命令进行Extended description

git commit -am "My commit text" "My Extended description is this. Containing break lines in it."

There is no " extended description " concept in git. git中没有“ 扩展描述 ”的概念。 Only the commit message . 提交消息 What happens is that the commit message can have a single line or multiple lines. 什么情况是,在提交信息可以有一个 或多行。

External tools or websites such as git-cola or GitHub can interpret multiple lines commit messages as: 外部工具或网站(例如git-colaGitHub)可以将多行提交消息解释为:

  • The first line is a short description 第一行是简短说明
  • All the other lines are an extended description 所有其他行都是扩展说明

For one line messages, only the " short description " is defined. 对于一行消息,仅定义“ 简短描述 ”。

See GitHub commit with extended message for details. 有关详细信息 ,请参见带有扩展消息的GitHub commit

As ckruczek suggested you can simply git commit without option and a text editor will spawn, just write the first line as the short description and the rest as the extended description. 正如ckruczek所建议的那样,您可以简单地使用git commit不带选项,并且会生成一个文本编辑器,只需将第一行写为简短描述,其余写为扩展描述。

If you want to do it from the command line, you can use one of the options mentionned in this question: Add line break to git commit -m from command line . 如果要从命令行执行此操作,则可以使用此问题中提到的选项之一: 从命令行向git commit -m添加换行符

For example with bash, you can do: 例如,使用bash,您可以执行以下操作:

git commit -m 'Message
goes
here'

Or use the "here document" syntax: 或使用“此处文档”语法:

git commit -F- <<EOF
Message
goes
here
EOF

PS: Examples are taken directly from the answer in Add line break to git commit -m from command line . PS:示例直接取自命令行中将换行符添加到git commit -m中的答案。 Credits for Simon Ritcher and jpmc26 . 感谢Simon Ritcherjpmc26

As a third way, you could also use a temporary file: 第三种方法,您还可以使用一个临时文件:

echo $comment > message.tmp
echo $extended >> message.tmp
git commit -F message.tmp
rm message.tmp

There is also another option (also described in this question answer ): You can specify multiple messages using the ' -m ' option multiple times: 还有另一个选项(也在此问题答案中描述):您可以多次使用' -m '选项指定多个消息:

git commit -m "Short description" -m "Extended description"

Be careful as, specified this way, messages will be treated as paragraph , thus beeing separated by an empty line. 请注意,以这种方式指定的消息将被视为段落 ,因此蜂鸣声由空行分隔。

From the online git doc : 在线git doc

-m <msg> -m <消息>
--message=<msg> --message = <MSG>

Use the given <msg> as the commit message. 使用给定的<msg>作为提交消息。 If multiple -m options are given, their values are concatenated as separate paragraphs. 如果给出了多个-m选项,则它们的值将串联为单独的段落。

When you git commit , you get an editor. 当您git commit ,您会得到一个编辑器。 The first line is the subject of the commit and should be a short description (less than 50 characters) in the present continuous tense. 第一行是提交的主题,应该是当前连续时态的简短描述(少于50个字符)。 Then a new line and an "extended description" which should contain more details wrapped to 72 columns. 然后是新行和“扩展描述”,其中应包含包装为72列的更多详细信息。 This is probably what git cola is doing is doing under the hood. 这可能是git cola在后台执行的操作。 http://chris.beams.io/posts/git-commit/ is a nice article on the structure of a commit message. http://chris.beams.io/posts/git-commit/是有关提交消息的结构的不错的文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM