I have about 22 repositories on bitbucket and downloading them can be a pain. Here’s a short script to make life easier:
#!/bin/bash #Script to get all repositories under a user from bitbucket #Usage: getAllRepos.sh [username] curl -u ${1} https://api.bitbucket.org/1.0/users/${1} > repoinfo for repo_name in `grep \"name\" repoinfo | cut -f4 -d\"` do hg clone ssh://hg@bitbucket.org/${1}/$repo_name done
UPDATE: Corrected a typo. Many thanks to fr3d3r1cbaz1n for pointing it out! Also, as fr3d3r1cbaz1n noted, this script only works for Mercurial but git users can easily change the hg command to git.
very helpful. Thank you !
there is typo in filename. saving to repoinfo but reading from repoinfo.txt
Also ,the script is not detecting repo type properly though. I was lazy to implement that part .
As my repos are all git ,I just replace hg line with
git clone git@bitbucket.org:${1}/$repo_name.git
The line:
for repo_name in `grep \”name\” repoinfo | cut -f4 -d\”`
should actually be:
for repo_name in `grep \”slug\” repoinfo | cut -f4 -d\”`
The repo name on bitbucket can actually be a verbose name, while the slug is used in the URL for the repo.
Would love to see an indempotent script that would git pull repo’s that already existed. Will post here if I get to it 🙂