git commit 的时候如何添加大段的注释
ringa_lee
ringa_lee 2017-04-24 09:11:34
0
7
796

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

git commit -a

会出现

Aborting commit due to empty commit message.

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

ringa_lee
ringa_lee

ringa_lee

全部回复(7)
刘奇

首先,使用下面这个命令来设置git默认的编辑器,其中的“editor”替换成你自己的编辑器,如Vim、Emacs、gedit、subl等:

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

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

黄舟

用macvim做commit时的编辑器,用-f参数能避免下面的提示.-w无效.

Aborting commit due to empty commit message.

在终端修改git config如下

git config --global core.editor "/bin/mvim -f"
左手右手慢动作

可以查看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

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

Ty80
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 # 编辑器添加提交信息
Ty80

git commit -am “bla bla bla”

Peter_Zhu

楼主使用过 git gui 没?不过,git commit -m "your description"命令方便下次快捷提交而已。

PHPzhong

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

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!