From c8f54de1f6eeb5051fd82b9d814cdea0cd6fe053 Mon Sep 17 00:00:00 2001 From: Stefan Gaiselmann Date: Fri, 19 Sep 2025 11:40:47 +0200 Subject: [PATCH] (git): Add script to diff a single file with all existing branches. Created with help of ChatGPT. --- bin/git-diff-file-for-branches | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bin/git-diff-file-for-branches diff --git a/bin/git-diff-file-for-branches b/bin/git-diff-file-for-branches new file mode 100644 index 0000000..0c10b63 --- /dev/null +++ b/bin/git-diff-file-for-branches @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# File to compare +FILE="$1" + +if [[ -z "$FILE" ]]; then + echo "Usage: $0 " + 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