20

When doing a regular git commit, git commit --verbose shows the diff in the text editor when writing the commit message.

Suppose I am doing an interactive rebase (git rebase --interactive) to edit previous commits. To 'continue' rebasing, I run git rebase --continue. This opens a text editor for editing the commit message, but it does not show the diff. After making changes to a commit, how can I display the diff when (re)writing the commit message during an interactive rebase?

git rebase --continue --verbose doesn't seem like a valid command...

4
  • When does git rebase --continue open a text editor? Commented Dec 27, 2017 at 9:58
  • @Arkadiusz Drabczyk After selecting commits to edit during an interactive rebase, and after git add to mark the changes, git rebase --continue opens a text editor. Commented Dec 27, 2017 at 20:56
  • hmm, ok, I think I got. See my answer. Commented Dec 27, 2017 at 21:12
  • 1
    Somewhat related: stackoverflow.com/questions/16721183/… Commented Dec 27, 2017 at 23:09

3 Answers 3

16

To show the diff:

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

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.

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

1 Comment

To enable verbose commits for the current user from the command line, execute git config --global commit.verbose true
2

You can do:

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

If you get tired copying that command you can create an alias in your ~/.gitconfig:

[alias] myrebasecontinue = "!git -c commit.verbose=true rebase --continue" 

And now just do:

git myrebasecontinue 

2 Comments

Hmm that doesn't seem to show the diff. Does it matter that I'm using git 2.7.4?
Yes, a quick look at git source shows that commit.verbose was introduced in git 2.9
1

In the middle of a rebase,

git diff 

shows you the changes not yet added to the commit,

git diff --cached 

shows you the new changes you committed, and

git show 

shows you the original changes in the commit you're editting.

4 Comments

Yes I am aware of that. What I'm asking for is to show the diff within the text editor (similar to that shown for git commit --verbose).
@Flux, I do :r !git diff in Vim, no idea whether there's something in Git itself to do this automatically. I'm afraid, there isn't.
You can always write a script that runs the git commands, captures the output to a temp file, opens it in your editor (in the background), and runs git rebase --continue.
This is exactly what I was googling for! Nice

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.