fetch-all.sh: use git-branch - still "echo", no real command
This commit is contained in:
@@ -2,16 +2,21 @@
|
|||||||
|
|
||||||
origin=origin
|
origin=origin
|
||||||
|
|
||||||
declare -a remotes local
|
declare -a remotes local_b
|
||||||
|
#declare -A aremotes
|
||||||
|
declare -A alocal_b
|
||||||
|
|
||||||
|
# get remotes list
|
||||||
readarray -t remotes < <(git remote)
|
readarray -t remotes < <(git remote)
|
||||||
declare -A aremotes alocal_b
|
|
||||||
|
|
||||||
# fetch all remotes
|
# fetch all remotes
|
||||||
for remote in "${remotes[@]}"; do
|
git fetch --all
|
||||||
aremotes["$remote"]=1
|
|
||||||
echo doing git fetch -a "$remote"
|
# fill associative array with remote
|
||||||
done
|
#for remote in "${remotes[@]}"; do
|
||||||
|
# aremotes["$remote"]=1
|
||||||
|
# echo doing git fetch -a "$remote"
|
||||||
|
#done
|
||||||
|
|
||||||
# get local branches
|
# get local branches
|
||||||
readarray -t local_b < <(git for-each-ref --format='%(refname:short)' refs/heads/)
|
readarray -t local_b < <(git for-each-ref --format='%(refname:short)' refs/heads/)
|
||||||
@@ -21,23 +26,25 @@ for ref in "${local_b[@]}"; do
|
|||||||
alocal_b[$ref]=1
|
alocal_b[$ref]=1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# get origin branches
|
||||||
readarray -t orig_b < <(git for-each-ref --format='%(refname:short)' \
|
readarray -t orig_b < <(git for-each-ref --format='%(refname:short)' \
|
||||||
refs/remotes/"$origin"/)
|
refs/remotes/"$origin"/)
|
||||||
|
|
||||||
declare -p remotes
|
declare -p remotes
|
||||||
#declare -p aremotes
|
|
||||||
declare -p local_b orig_b
|
declare -p local_b orig_b
|
||||||
|
|
||||||
# find-out missing local branches
|
# find-out missing local branches and track them
|
||||||
for remote_b in "${orig_b[@]}"; do
|
for remote_b in "${orig_b[@]}"; do
|
||||||
short=${remote_b#"$origin"/};
|
short=${remote_b#"$origin"/};
|
||||||
echo "$remote_b -> $short ${alocal_b[$short]}"
|
#echo "$remote_b -> $short ${alocal_b[$short]}"
|
||||||
if ! [[ -v alocal_b[$short] ]]; then
|
if ! [[ -v alocal_b[$short] ]]; then
|
||||||
echo git switch -t "$remote_b"
|
echo git branch --track "$short" "$remote_b"
|
||||||
|
# echo git branch: "$remote_b"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo git pull --all
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user