Adam Monsen
Adam Monsen

Reputation: 9420

How do I make git show diff when rewording a commit message during rebase -i?

I always use git commit --verbose. Is there an equivalent option/setting that will make git show me the diff when I'm rewording a commit message during git rebase --interactive?

Upvotes: 32

Views: 3257

Answers (3)

Hugh W
Hugh W

Reputation: 1186

In another terminal (or from your editor) run:

git show

Upvotes: 0

Vampire
Vampire

Reputation: 38619

According to your answers in the comments, executing git diff HEAD^ will not help you, except if you only want to reword the last commit.

But in this case a rebase is the wrong tool anyway. Instead you can simply do git commit --amend --verbose without changes in the index and then edit the commit message, having the diff view you are asking for.

If you want to reword an older or multiple commit messages with having the diff view, just use the edit stanza instead of the reword stanza and then use git commit --amend --verbose without code changes in the index on each of the commits.

reword should only be a shortcut for using edit and then do git commit --amend -m "new message" without any changes which will only change the commit message.

You can also define git commit --amend --verbose or git commit --verbose as alias so you save some typing and can e.g. simply do git cav or git c --amend.

Upvotes: 14

Flux
Flux

Reputation: 10920

To show the diff:

git -c commit.verbose=true rebase --interactive

To make all commits verbose without having to specify -c commit.verbose=true every time, add this to ~/.gitconfig:

[commit]
    verbose = true

Reference: man git-config.

Upvotes: 11

Related Questions