2022-04-19

git diff after a rebase

After doing a particularly hairy rebase, you want to check what changed (intentionally or otherwise), but only in the files you worked on originally.

After rebasing, you try:

git diff origin/my-special-branch my-special-branch

But there's a load of changes that other contributors have made that you don't care about!

Here's how to restrict the diff:

BRANCH=my-special-branch; git diff origin/$BRANCH $BRANCH -- $(git diff master $BRANCH --name-only)