Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Last active February 19, 2016 12:26
Show Gist options
  • Save emad-elsaid/bef36a9e76707d0c3253 to your computer and use it in GitHub Desktop.
Save emad-elsaid/bef36a9e76707d0c3253 to your computer and use it in GitHub Desktop.
Clone all bitbucket repositories to directory
#!/bin/bash
#Script to get all repositories under a user from bitbucket
#Usage: getAllRepos.sh [username]
#source: http://haroldsoh.com/2011/10/07/clone-all-repos-from-a-bitbucket-source/
curl -u ${1} https://api.bitbucket.org/1.0/users/${1} > repoinfo
# curl -u adomingues https://api.bitbucket.org/1.0/users/adomingues
# cat 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
git clone [email protected]:${1}/$repo_name.git
echo "---"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment