带有扩展消息/描述的 Git/GitHub 提交

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9562304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:34:03  来源:igfitidea点击:

Git/GitHub commit with extended message/description

gitmacosgithub

提问by Adrian Gunawan

I recently use GitHub and downloaded GitHub for Mac.

我最近使用 GitHub 并下载了 Mac 版 GitHub。

I noticed you can add an 'extended description' using GitHub for Mac. How do I add an extended description using the command line?

我注意到您可以使用 GitHub for Mac 添加“扩展描述”。如何使用命令行添加扩展描述?

Can I add an extended description to an existing commit?

我可以向现有提交添加扩展描述吗?

回答by duskwuff -inactive-

Run git commitwithout a message and it'll open up your favorite* text editor to write a commit message. Details on the format of the message will appear in the sample.

git commit没有消息的情况下运行,它会打开您最喜欢的* 文本编辑器来编写提交消息。有关消息格式的详细信息将出现在示例中。

First line is the short description. Leave a blank line after it. Everything else is the extended description.

第一行是简短的描述。在它后面留一个空行。其他一切都是扩展描述。

*: for some values of "favorite"; results may vary

*:对于“最喜欢”的某些值;结果可能会有所不同

回答by 1j01

From this accepted answer:

从这个接受的答案

git commit -m "Title" -m "Description .........."

回答by stephen.hanson

Actually, you can do this quite easily from the command line. The trick is to type your message (without a closing quote!) and then hit enter twice, and then type your extended message, close the quote and press enter.

实际上,您可以从命令行轻松完成此操作。诀窍是键入您的消息(没有结束引号!)然后按两次 Enter,然后键入您的扩展消息,关闭报价并按 Enter。

It should look like:

它应该看起来像:

$ git commit -m "Make everything work.
dquote>
dquote> Add magic code that fixes everything"

GitHub will correctly display the top line as your basic message and the bottom line as the extended message.

GitHub 将正确地将顶行显示为您的基本消息,将底行显示为扩展消息。

The following does NOT work. You end up with the literal "\n\n" in the commit message: $ git commit -m "Basic msg\n\nExtend msg, doesnt work".

以下不起作用。你最终用文字“\ n \ n”,在提交信息:$ git commit -m "Basic msg\n\nExtend msg, doesnt work"