From 7a87c3282b25da966492dc19a51c0b29c280d727 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Mon, 17 Jun 2024 14:46:43 +0200 Subject: [PATCH] zobi --- README.md => README.mv.copy | 0 fetch-all.sh | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) rename README.md => README.mv.copy (100%) create mode 100755 fetch-all.sh diff --git a/README.md b/README.mv.copy similarity index 100% rename from README.md rename to README.mv.copy diff --git a/fetch-all.sh b/fetch-all.sh new file mode 100755 index 0000000..44f03a9 --- /dev/null +++ b/fetch-all.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +origin=origin + +declare -a remotes local + +readarray -t remotes < <(git remote) +declare -A aremotes alocal_b + +# fetch all remotes +for remote in "${remotes[@]}"; do + aremotes["$remote"]=1 + echo doing git fetch -a "$remote" +done + +# get local branches +readarray -t local_b < <(git for-each-ref --format='%(refname:short)' refs/heads/) + +# build local ref array +for ref in "${local_b[@]}"; do + alocal_b[$ref]=1 +done + + +readarray -t orig_b < <(git for-each-ref --format='%(refname:short)' \ + refs/remotes/"$origin"/) + +declare -p remotes +#declare -p aremotes +declare -p local_b orig_b + +# find-out missing local branches +for remote_b in "${orig_b[@]}"; do + short=${remote_b#"$origin"/}; + echo "$remote_b -> $short ${alocal_b[$short]}" +done + + + + + + +#git remote | xargs -n 1 git fetch -a