我分阶段更改,我运行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 钩子
如果你肯定想要十条消息,你可以使用 Git 钩子the prepare-commit-msg
。
将以下行作为prepare-git-commit-msg
文件的内容放在.git/hooks
文件夹中。
#!/bin/sh
git log -10 --oneline >> $1
它会将最后十条消息添加到提交消息的模板中
将以下内容放入.git/hooks
目录中名为 prepare-commit-msg
的文件中:
#!/bin/sh
temp=`cat $1`
git log -10 --oneline > $1
echo "$temp" >> $1