简体   繁体   中英

Extended message for commit via Visual Studio Code?

I know, with command line I can do this:

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

Is there way to do this via Git Version Control in VS Code ?

First, people are often misunderstanding what this command actually does. It is important to know what happens behind the scene.

So, this is from the git commit documentation :

If multiple -m options are given, their values are concatenated as separate paragraphs.

Therefore when providing a commit message in Team Explorer, try separating your title from your description in separate paragraphs and it should have the same behavior as your command-line example.

This command is not as magic as it seems. To see a live implementation. see this answer which really shows it well.

Is there way to do this via Git Version Control in VS Code?

Absolutely!
In VS code you can create messages and descriptions without using the command-line at all.

I discovered this by reading about commit messages from the command line as noted in the link above. If the message contains more than one paragraph of text, subsequent lines/paragraphs become the description. So, I decided to try this using the commit message window in VS Code and it worked!

Summary
When you create your commit and you type in the commit message, simply hit the enter key a couple of times and then begin adding details. The first line becomes the commit "message" and any subsequent paragraphs of text become the commit's description.

Example:
I created a text file and committed it to my current project with some explanatory text.

This is a detail view from within VS Code showing how to create a commit message with additional descriptive details:

显示多行提交消息的视图

Oops! I forgot something - adding additional text before the commit.

Here I have added an additional line of text showing that the "detail" part of the commit can have multiple paragraphs.

VS Code 中的第二个视图,显示多个段落描述

Once the commits are done and pushed (to GitHub in my case), you can go there and view the results.

This is the view of the commit overview from within GitHub: GitHub 中的提交概述显示提交消息

And this is the way the commit message and commit message details look when you click on the message in the overview: 这是 GitHub 中的提交消息详细信息

There's an additional very interesting feature I stumbled across by accident:
If you mouse-over the commit message within GitHub, it shows a tool tip with the message and message details on the summary page! 提交消息概述显示带有描述性文本的工具提示

The above does not seem to work on my VS Code. It shows the following greyed out message. commit message . What am I missing here?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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