Skip to content

Instantly share code, notes, and snippets.

@1242035
Last active March 16, 2019 03:31
Show Gist options
  • Save 1242035/2490c737fe853bdf73c509ea4a5e6f70 to your computer and use it in GitHub Desktop.
Save 1242035/2490c737fe853bdf73c509ea4a5e6f70 to your computer and use it in GitHub Desktop.
Get all repositories under a user from bitbucket
#!/bin/bash
#Script to get all repositories under a user from bitbucket
#Origin: https://haroldsoh.com/2011/10/07/clone-all-repos-from-a-bitbucket-source/
#Usage: ./clone.sh [username] [password]
curl -u ${1}:${2} https://api.bitbucket.org/1.0/users/${1} > repoinfo
for repo_name in `cat repoinfo | sed -r 's/("name": )/\n\1/g' | sed -r 's/"name": "(.*)"/\1/' | sed -e 's/{//' | cut -f1 -d\" | tr '\n' ' '`
do
echo "Cloning: " $repo_name
git clone https://${1}:${2}@bitbucket.org/${1}/$repo_name".git"
echo "Cloning all branch " $repo_name
cd $repo_name
git pull --all
cd ..
echo "----------------------------------------------------------------"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment