Could such a difference occur even when there were no conflicts?
Perhaps not, but human error is a factor that we must always consider.
Is there a way to get a (huge flashing) warning when a difference occurs?
This should do:
git diff ORIG_HEAD HEAD
To do this automatically, use the post-rewrite hook (see Git Hooks ):
after rewriting
This hook is called by commands that rewrite commit (git commit --amend, git -rebase; currently git -filter-branch does not call it!). His first argument indicates the command to which he was called: currently one of the changes or rebase. In the future, additional arguments depending on the command may be passed.
Then in the hook script .git/hooks/post-rewrite we can compare ORIG_HEAD and HEAD and issue a warning if it is different:
To make the hook accessible worldwide, consider the configuration of core.hooksPath , for example:
git config --global core.hooksPath /usr/local/git-hooks/
Then save the script as /usr/local/git-hooks/post-rewrite , with the permission set set.
NOTE : unfortunately, it seems that the error related to the fact that interactive forwarding, namely git rebase -i , does not trigger the hook when using custom dir. (I am using git 2.9.2)
source share