git commit
打开文本编辑器,并显示有关要提交的更改的某些信息:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
我想扩展这个模板来显示:
- 最近
N
次提交的第一行消息和/或 - 最后一次提交的完整消息
当前分支的。我该怎么做?
printf
结尾添加\n
(它不像echo
一样包含换行符)。 - Brian Campbelltrap "rm -f $TEMP" exit
。 - Brian Campbellprintf
,通常应使用格式字符串并将$MSG
作为单独变量提供,以便它不会被解释为格式字符串。printf "\n\n# 最后提交:%s \n\n" "$MSG"
。您不想让提交消息“用\r\n替换\n以实现Windows兼容性”导致这些实际换行符出现在您的模板中。 - Brian Campbell