Skip to content

Instantly share code, notes, and snippets.

@sandeepkunkunuru
Created February 21, 2016 17:46
Show Gist options
  • Save sandeepkunkunuru/9c1cb4a9d780f03232ce to your computer and use it in GitHub Desktop.
Save sandeepkunkunuru/9c1cb4a9d780f03232ce to your computer and use it in GitHub Desktop.
Checkout all your bitbucket repos in one go
#!/bin/bash
#script to get all repositories under a user from bitbucket
#Usage: bitbucket.sh [username]
curl -u ${1} https://api.bitbucket.org/1.0/users/${1} > repoinfo
for repo_name in $( grep -oE '\"slug\": "[^"]*"' repoinfo | cut -f4 -d\")
do
if [[ -d "${repo_name}" ]]; then
pushd "${repo_name}"
git pull origin master
popd
else
git clone git@bitbucket.org:${1}/${repo_name}.git
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment