Clone all bitbucket projects
BBA=MyUserName; curl --user ${BBA} https://api.bitbucket.org/2.0/repositories/${BBA} | grep -o '"ssh:[^ ,]\+' | xargs -L1 git clone
The above curl
call will connect to the server using your username
and return the list of repositories that are available to your account.
Please note that you need to provide you username NOT your email.
If you make these calls using the email that was used to register the account, then the call will fail.
After the call succeeds, the results will be filtered and each repository will be cloned to the current folder.
In case your ssh key is locked via a password, each time a clone operation will start, you will be asked for the password.
Example:
BBA="bytefreaks"; curl --user ${BBA} https://api.bitbucket.org/2.0/repositories/${BBA} | grep -o '"ssh:[^ ,]\+' | xargs -L1 git clone Enter host password for user 'bytefreaks': % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3834 100 3834 0 0 4414 0 --:--:-- --:--:-- --:--:-- 4411 Cloning into 'bluetoothclicker'... Warning: Permanently added the RSA host key for IP address '104.192.143.1' to the list of known hosts. Enter passphrase for key '/home/bytefreaks/.ssh/BitBucket/id_rsa': warning: You appear to have cloned an empty repository. Checking connectivity... done. Cloning into 'watch'... Enter passphrase for key '/home/bytefreaks/.ssh/BitBucket/id_rsa': warning: You appear to have cloned an empty repository. Checking connectivity... done.
List all bitbucket projects
In case what you want is just to list your repositories, execute the following:
curl --user ${BBA} https://api.bitbucket.org/2.0/repositories/${BBA} | grep -o '"ssh:[^ ,]\+' | xargs -L1 echo
Usage instructions: set your username
to the BBA
variable and execute.
BBA="bytefreaks"; curl --user ${BBA} https://api.bitbucket.org/2.0/repositories/${BBA} | grep -o '"ssh:[^ ,]\+' | xargs -L1 echo Enter host password for user 'bytefreaks': % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3834 100 3834 0 0 3543 0 0:00:01 0:00:01 --:--:-- 3546 ssh://[email protected]/bytefreaks/bluetoothclicker.git ssh://[email protected]/bytefreaks/watch.git
This post is also available in: Αγγλικα