32

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?

6
  • 8
    I don’t think so. How about doing it yourself in the editor, e.g. in vi :r !git diff HEAD^ or similar? Commented May 23, 2013 at 18:40
  • @chirlu ooh yeah, that's a handy workaround, thank you. Commented May 23, 2013 at 18:41
  • @AdamMonsen, how do you "reword a commit message during git rebase --interactive"? Do you do it in the initial screen, replacing "pick" by "reword" and giving the new message directly, or do you replace "pick" by "edit" and use "git commit --amend" to change the commit message? Commented May 25, 2013 at 0:03
  • @Vampire, good question. I'm talking about the former: changing "pick" to "reword". But simply using "edit" sounds like another great workaround! There may be some other differences between "reword" and "edit" (besides the obvious user-visible ones), I don't know. Commented May 25, 2013 at 4:58
  • 1
    Related: Show diff when writing commit messages during an interactive rebase Commented Jun 13, 2019 at 5:48

3 Answers 3

14

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Instead of using the edit command in an interactive rebase which will drop you to the shell where have to type git commit --amend --verbose to edit the commit and then git rebase --continue you can simply add a line after the respective commit with exec git commit --amend --verbose. This will drop you directly into the editor for that commit and continue the rebase after you exit the editor.
Ah nice, somehow didn't ever consider exec stanza.
12

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.

Comments

0

In another terminal (or from your editor) run:

git show 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.