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
?
To see the diff for a particular COMMIT hash, where COMMIT is the hash of the commit: git diff COMMIT~ COMMIT will show you the difference between that COMMIT 's ancestor and the COMMIT . See the man pages for git diff for details about the command and gitrevisions about the ~ notation and its friends.
On the command line, navigate to the repository that contains the commit you want to amend. Use the git rebase -i HEAD~n command to display a list of the last n commits in your default text editor. Replace pick with reword before each commit message you want to change.
"reword" allows you to change ONLY the commit message, NOT the commit contents. "edit" allows you to change BOTH commit contents AND commit message (the mechanism by which git allows you to edit the commit contents is by "pausing" the rebase; so you can amend the commit)
There are many ways to rewrite history with git. Use git commit --amend to change your latest log message. Use git commit --amend to make modifications to the most recent commit. Use git rebase to combine commits and modify history of a branch.
According to your answers in the comments, executing git diff HEAD^
will not help you, except you only want to rewored 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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With