Skip to content

Instantly share code, notes, and snippets.

@mythmon
Created May 16, 2025 20:39
Show Gist options
  • Save mythmon/7a49d727691cf024ce2cde22a3206aa1 to your computer and use it in GitHub Desktop.
Save mythmon/7a49d727691cf024ce2cde22a3206aa1 to your computer and use it in GitHub Desktop.

This script is supposed to make it easier to use git range-diff to compare how a branch has changed over time. When GitHub says "@mythmon force pushed from abcdef to 123456", you can run git-interdiff.sh abcdef 123456 to get a difference of each of those branches, based on where they departed from the main branch.

Note that if this script is named to git-interdiff and placed on your $PATH, you can run it as git interdiff.

#!/usr/bin/env bash
# Check if both arguments are provided
if [ $# -lt 2 ]; then
echo "Error: Not enough arguments provided."
echo "Usage: $0 <first_commit> <second_commit>"
exit 1
fi
first=$1
second=$2
git range-diff $(git merge-base origin/main $first)..$first $(git merge-base origin/main $second)..$second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment