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

为什么我在用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學習者快速成長!