Add a hash/pound symbol as the first character in a git commit message in vim

佐手、 提交于 2020-01-11 09:48:47

问题


GitHub (probably, wrongly) uses #'s when referring to GitHub issues. So I would like to add a commit message that refers to the issue on the first line.

e.g.

#12: New commit

- Did a thing
- Did another thing

Vim/git ignores lines starting with #'s though so I'm not sure how to escape it 🤷‍♂️


回答1:


Git allows you to update the comment char from the # symbol to any other. Then you can use the # symbol.

e.g.

git config core.commentChar '>'

or optionally set it globally

git config --global core.commentchar '>'



回答2:


The simplest way to avoid git interpreting the issue number as a comment line, is to insert another character before, so the # is not the leading character of the line (a space will do the trick).

Here is an example:

#45

will be seen as a comment

 #45
Issue #45

will both be taken entirely as commit messages



来源:https://stackoverflow.com/questions/56799689/add-a-hash-pound-symbol-as-the-first-character-in-a-git-commit-message-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!