git commit 的时候如何添加大段的注释

 mobiledu2502863015 发布于 2022-10-26 15:36

为什么我在用osx上的git的时候用

git commit -a

会出现

Aborting commit due to empty commit message.

的确会跳出编辑器让我输入commit信息,但是保存之后tig中依然没有提交的信息,也就是之前被那个空消息错误给打断了,但是照理来说不是可以通过这个方法来编写大段的commit信息么,难道需要做什么配置,求教

7 个回答
  • git commit
    然后就写你的提交注释吧。
    注:第一行尽量简洁吧,控制在 50 个字符内,然后空一行,再继续写详细的注释。

    另,可以参考这个:「写出好的 commit message」

    2022-10-27 01:16 回答
  • 楼主使用过 git gui 没?不过,git commit -m "your description"命令方便下次快捷提交而已。

    2022-10-27 01:16 回答
  • git commit -am "bla bla bla"

    2022-10-27 01:16 回答
  • git config --global core.editor "[your editor] -w"
    

    -w 通知Git使用自已指定的编辑器

    Git使用方法:

    touch README.md
    git init
    git add README.md
    # git commit -m "first commit" # 命令行添加提交信息
    git commit # 编辑器添加提交信息
    
    2022-10-27 01:16 回答
  • 可以查看Git帮助。
    -m , --message=
    Use the given as the commit message.

    根据给定的信息进行注释,注释内容要用双引号扩起来
    -a, --all
    Tell the command to automatically stage files that have been
    modified and deleted, but new files you have not told git about are
    not affected

    列出所有修改和删除的文件,但是新文件并不列出。

    2022-10-27 01:16 回答
  • 用macvim做commit时的编辑器,用-f参数能避免下面的提示.-w无效.

    Aborting commit due to empty commit message.

    在终端修改git config如下

    git config --global core.editor "/bin/mvim -f"
    
    2022-10-27 01:16 回答
  • 首先,使用下面这个命令来设置git默认的编辑器,其中的“editor”替换成你自己的编辑器,如Vim、Emacs、gedit、subl等:

    git config --global core.editor "editor -w"
    

    然后,在做提交的时候使用命令不要写"-m"参数,直接写成git commit这样子就行,这样就会自动打开你刚才指定的编辑器,你可以在里面添加大段注释。

    2022-10-27 01:17 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有