dotfiles/bin/git-diff-file-for-branches

25 lines
438 B
Bash

#!/usr/bin/env bash
# File to compare
FILE="$1"
if [[ -z "$FILE" ]]; then
echo "Usage: $0 <file>"
exit 1
fi
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo current: $CURRENT_BRANCH
for BRANCH in $(git for-each-ref --format='%(refname:short)' refs/heads/); do
if [[ "$BRANCH" == "$CURRENT_BRANCH" ]]; then
continue
fi
echo "=== Diff vs $BRANCH ==="
git diff "$BRANCH" -- "$FILE"
echo
done