Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use `git commit -v` with `git rebase -i`

When doing a git rebase -i and, say, squashing two commits together, Git will bring up an editor with the commit messages in it for me to edit.

Normally when I do a stand-alone git commit, I use the -v option so that the message file I'm editing also includes, below the "cut" line, a diff of the commit against the previous commit.

How do I get this same commit -v behaviour when I'm doing an interactive rebase? (Note that I can't just type git commit -v manually, since the commit process is started and run for me by git rebase -i.)

like image 572
cjs Avatar asked Jul 24 '26 12:07

cjs


1 Answers

One option is to set commit.verbose to true in your git configuration:

git config --global commit.verbose true

With this setting you will always get the git commit -v behavior, without needing to specify -v. If you don't want this turned on all the time, the git-config man page suggests an alternative in the documentation on creating aliases:

Note that the first word of an alias does not necessarily have to be a command. It can be a command-line option that will be passed into the invocation of git. In particular, this is useful when used with -c to pass in one-time configurations or -p to force pagination. For example, loud-rebase = -c commit.verbose=true rebase can be defined such that running git loud-rebase would be equivalent to git -c commit.verbose=true rebase...

like image 156
larsks Avatar answered Jul 26 '26 19:07

larsks