(git): Add script to diff a single file with all existing branches.
Created with help of ChatGPT.
This commit is contained in:
parent
ab384ea810
commit
c8f54de1f6
24
bin/git-diff-file-for-branches
Normal file
24
bin/git-diff-file-for-branches
Normal file
@ -0,0 +1,24 @@
|
||||
#!/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
|
||||
Loading…
Reference in New Issue
Block a user