Home  >  Q&A  >  body text

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

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

git commit -a

会出现

Aborting commit due to empty commit message.

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

ringa_leeringa_lee2734 days ago798

reply all(7)I'll reply

  • 怪我咯

    怪我咯2017-04-24 09:13:34

    First, use the following command to set git默认的编辑器,其中的“editor" and replace it with your own editor, such as Vim, Emacs, gedit, subl, etc.:

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

    Then, when making a submission, use the command instead of writing "-m"参数,直接写成git commitJust like this, it will automatically open the editor you just specified, and you can add large comments in it.

    reply
    0
  • 黄舟

    黄舟2017-04-24 09:13:34

    Using macvim as the editor for commit, using -f参数能避免下面的提示.-whas no effect.

    Aborting commit due to empty commit message.

    Modify git config in the terminal as follows

    git config --global core.editor "/bin/mvim -f"
    

    reply
    0
  • ringa_lee

    ringa_lee2017-04-24 09:13:34

    You can view Git help.
    -m , --message=
    Use the given as the commit message.

    Comment based on the given information. The comment content should be enclosed in double quotes.
    -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

    All modified and deleted files are listed, but new files are not.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-24 09:13:34

    git config --global core.editor "[your editor] -w"
    

    -w tells Git to use the specified editor

    How to use Git:

    touch README.md
    git init
    git add README.md
    # git commit -m "first commit" # 命令行添加提交信息
    git commit # 编辑器添加提交信息
    

    reply
    0
  • PHP中文网

    PHP中文网2017-04-24 09:13:34

    git commit -am "bla bla bla"

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-24 09:13:34

    Have you ever used git gui? However, the git commit -m "your description" command is just for quick submission next time.

    reply
    0
  • PHPz

    PHPz2017-04-24 09:13:34

    git commit
    Then just write your commit comments.
    Note: Keep the first line as concise as possible, within 50 characters, then leave a blank line before continuing to write detailed comments.

    Also, you can refer to this: "Write a good commit message"

    reply
    0
  • Cancelreply