有没有办法在“git rebase -i”(交互式)中列出提交的作者?

Is there a way to list the commit's author in `git rebase -i` (interactive)?

当我在与同事共享的分支上执行 git rebase -i 时,我经常只想重新设置自己的提交。但是,由于交互式变基工具不会将作者信息添加到变基文件中(t 给出的只是提交哈希和描述),我最终不得不去检查另一个选项卡中的提交以查看它们是否是我的。

有什么方法可以给 git rebase -i 一个 --format 标志(或类似的东西),使其包括作者?

从git 2.6开始,git rebase -i使用rebase.instructionFormat(默认%s)生成pick NNNNN...后的文本。

由于这是一个 git-config 项,您可以设置每个存储库的值,通常为您自己设置,甚至可以一次性使用 -c 选项。

编辑:

正如 jdknight 在评论中所建议的,具体的命令是:

git config --add rebase.instructionFormat "(%an <%ae>) %s" 

或者,为了避免项目重复,正如老大所建议的,您可以改为全局设置配置:

git config --global rebase.instructionFormat "(%an <%ae>) %s"

编辑您的 .gitconfig 以添加:

[rebase]
    instructionFormat = %s [%an]

这将显示简短的提交消息,然后在方括号中显示作者姓名。

git -c "rebase.instructionFormat=(%an <%ae>) %s" rebase -i COMMIT_HASH

交互式输出将如下所示:

pick b596a7b (Nik Sumeiko <email@example.com>) Refactors type checking utilities
pick c8b815f (Attila Kerekes <email@example.com>) Implements commit message linting