在rebase -i期间重写提交消息时如何制作git show diff?

Ada*_*sen 27 git rebase

我总是用git commit --verbose.是否有一个等效的选项/设置,当我在重写提交消息期间,git会让我看到差异git rebase --interactive

Vam*_*ire 12

根据你在评论中的答案,执行git diff HEAD^不会帮助你,除了你只想重写最后一次提交.

但在这种情况下,无论如何,rebase是错误的工具.相反,您可以简单地git commit --amend --verbose在索引中进行更改,然后编辑提交消息,具有您要求的差异视图.

如果要使用diff视图重写旧的或多个提交消息,只需使用edit节而不是reword节,然后git commit --amend --verbose在每个提交的索引中使用而不进行代码更改.

reword应该只是一个使用的快捷方式edit,然后不做git commit --amend -m "new message"任何只会更改提交消息的更改.

您也可以定义git commit --amend --verbosegit commit --verbose作为别名,以便您节省一些打字,例如,只需做git cavgit c --amend.

  • 无需在交互式 rebase 中使用“edit”命令,这会将您带到必须键入“git commit --amend --verbose”来编辑提交的 shell,然后键入“git rebase --continue”,您只需添加使用 `exec git commit --amend --verbose` 进行相应提交后的一行。这将使您直接进入该提交的编辑器,并在退出编辑器后继续变基。 (2认同)

Flu*_*lux 8

显示差异:

git -c commit.verbose=true rebase --interactive
Run Code Online (Sandbox Code Playgroud)

要使所有提交变得详细而不必-c commit.verbose=true每次都指定,请将其添加到~/.gitconfig

[commit]
    verbose = true
Run Code Online (Sandbox Code Playgroud)

参考:man git-config