0

So I have 3 repositories to clone. Im passing repository name as an array, Suppose Repos=("A" "B" "C"). The issue is that I want to run the 1st and 3rd cloning loop with checkout branch as develop and 2nd as master.

git_setup() {

    URI=path_to_repo

    arr=("$@")    
    for i in "${arr[@]}";
    do
    "git clone" "$URI/$i" "--progress --verbose -b develop" | tee -a $LOGFILE
    done
}
Repos=("A" "B" "C")

git_setup "${Repos[@]}"

I am Looping this because I have different values of A,B,C depending on the Environment. I thought of creating master and develop checkouts as variables and then passing through loop. Is it possible ?

torek
  • 448,244
  • 59
  • 642
  • 775
  • 1
    It's really not clear what you are asking. Your code has several quoting errors which you'll probably want to sort out first. – tripleee Nov 17 '22 at 16:05
  • The duplicate shows how to loop over pairs of arrays but that seems like a clumsy arrangement for this particular case. Maybe simply loop over `A B C` (you don't need an array at all for that) and add an `if`/`then`/`else` inside the loop to choose a different branch for B; or loop over pairs with `while read -r repo branch; do ... done < – tripleee Nov 17 '22 at 16:08

0 Answers0