Reputation: 1725
So I have several folders for a list of subdomains. Each folder contains the same script which dynamically guesses the host and loads several configs.
So the list is growing and cd to each folder to git pull is becoming a boring task.
My client's hosting service is limited and I cannot add a ssh key to the host in order for the pull to be "passwordless", so I make the pull via HTTPS.
Im not a bash expert but the basic loop would be:
for dir in /tmp/*/
do
#passwordless pulls
done
Now here is the catch, some folders needs to pull develop and others pull master branch.
Upvotes: 0
Views: 2327
Reputation: 60245
while read repo remote branch rest; do
( cd $repo
git pull $remote $branch
# do whatever with $rest
) 2>&1 | sed "s#^#$repo: #" &
done <<EOD
/path/to/repo origin branch1
/path/to/another github master
EOD
Or you could put the stuff in a file and </path/to/file
instead of inlining it after <<EOD
.
This will fire off all the pulls in parallel, if you have lots of them perhaps it'd be better to replace the &
at the end with a ;
(or equivalently here remove it).
Upvotes: 3
Reputation: 178
DEVLIST="list of hosts that pull develop"
MASTERLIST="list of hosts that pull master"
for D in ${DEVLIST}
do
cd /tmp/${D}
git clone https://my.repo.edu/git/repo.git -b develop --single-branch
done
for M in ${MASTERLIST}
do
cd /tmp/${M}
git clone https://my.repo.edu/git/repo.git -b master --single-branch
done
Upvotes: 1