编写新的提交消息时如何使用以前的提交消息?

How to use previous commit messages when composing new one?

我上演了变化,我运行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:
#   modified:   ...
#   ...

我还需要在此处查看 git log -10 --oneline 输出。怎么做?

备选方案 1,使用命令行标志

这将在配置的 git 编辑器中显示之前的提交消息

git commit -c HEAD --res

备选方案 2,使用 Git 钩子

如果你确定要十个消息,你可以使用the prepare-commit-msg Git hook

将以下行作为 prepare-git-commit-msg 文件的内容放入 .git/hooks 文件夹中。

#!/bin/sh
git log -10 --oneline >> 

它将最后十条消息添加到提交消息的模板中

将以下内容放入 .git/hooks 目录中名为 prepare-commit-msg 的文件中:

#!/bin/sh
temp=`cat `
git log -10 --oneline > 
echo "$temp" >>