Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

rebase

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?

like image 477
Adam Monsen Avatar asked May 23 '13 18:05

Adam Monsen


People also ask

How check diff after commit?

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.

How do I rebase a commit message?

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.

What is reword in git rebase?

"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)

How do I reword a commit message in git?

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.


1 Answers

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.

like image 121
Vampire Avatar answered Oct 25 '22 10:10

Vampire