美文网首页Android开发版本管理
git commit(-m)多行注释提交

git commit(-m)多行注释提交

作者: 淮左明都 | 来源:发表于2020-07-10 18:19 被阅读0次

在命令行上使用git时,你可能已经使用了消息标志(-m)。它允许开发人员在调用git commit时携带注释一起提交消息。

git commit -m "my commit message"

但是这种方式只能写一行的注释,如果你想要对commit的内容进行详细的讲解,以便仔细检查提交的文件,那你可能需要写多行注释,这个命令就不适用了。
今天,我了解到git commit命令接受多个消息标志,也就是多行注释😲
事实证明,你可以-m多次使用该选项。git文档包括以下段落:


即 “”
如果运行以下命令:
git  -m "commit title" -m "commit description"

这将导致该提交:

Author: stefan judis 
Date:   Tue Jul 7 21:53:21 2020 +0200

    commit title

    commit description

 test.txt | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

成功提交!你可以使用多个-m标志来创建“多行提交”,而且我不得不承认,在某些情况下这可能非常方便。

Ps:几个人指出,你还可以通过打开引号,按Enter并再次关闭带引号的提交来实现相同的提交结构,包括标题和正文(多行)

git commit -m "commit title
>
> commit description"

也可以达到相同的效果。

参考文章:git commit accepts several message flags (-m) to allow multiline commits

闲聊

最近有这个需要,刚好看到阮一峰老师的"科技爱好者周刊"里提及这种方法,所以做了一次搬运。


相关文章

  • git commit(-m)多行注释提交

    在命令行上使用git时,你可能已经使用了消息标志(-m)。它允许开发人员在调用git commit时携带注释一起提...

  • git命令小结

    常用指令 git add . //新建git commit -m "提交内容注释" -a ...

  • git 上传github

    快速开始 git init git add git commit -m "提交注释" git remote add...

  • git流程

    git流程git add . -->全部添加git commit -m "" -->本次提交注释git pul...

  • git之后上传代码步骤

    1:加载修改的文件:git add . 2:提交注释: git commit -m "annotation" 3:...

  • github项目提交

    git add . git commit -m "first commit"//提交到要地仓库,并写一些注释 gi...

  • git使用相关命令

    1、提交 git commit -m "注释" 文件名 2、查看提交日志 3、回退到某个版本 git reset ...

  • git简单使用

    初始化一个git库 git init 提交更改 git add git commit -m "注释"...

  • github上传本地项目

    git add . 添加文件 git commit -m 'xxx' //提交到本地仓库,并注释 git pull...

  • webstorm可视化操作合并代码到develop分支

    1.提交到本地 命令 git add 修改文件 git commit -m "注释信息" git status 查...

网友评论

    本文标题:git commit(-m)多行注释提交

    本文链接:https://www.haomeiwen.com/subject/rvimcktx.html