Created
September 17, 2019 03:48
-
-
Save abdennour/3b0071b821f4380f215841650fa8129c to your computer and use it in GitHub Desktop.
Backup All Git Repos with All branches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
team=${1}; | |
repos_list_file=${2}; | |
while read repo; do | |
if [[ ! -d "$repo" ]]; then | |
echo $repo clone... | |
git clone git@bitbucket.org:${team}/${repo}.git; | |
TIMEOUT=$((5 + RANDOM % 10)); | |
echo cloning next repo starts after $TIMEOUT seconds; | |
sleep $TIMEOUT; | |
else | |
cd $repo; | |
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done | |
git pull --all | |
cd ../; | |
fi | |
done < ${repos_list_file} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment