Skip to content

Create a repo on Bitbucket from the terminal

The biggest advantage of this is to create a new repo on Bitbucket and push your repo there without ever leaving the command line. It is quite simple to make a bash shell function that uses the Bitbucket API to create a new repo from the terminal using cURL.

Here is the function:

bitbucket-repo-create() {
    curl -X POST -v -u $USER:$PASS -H "Content-Type: application/json"$USER/$1 -d '{"scm": "hg", "is_private": "true", "fork_policy": "no_public_forks" }'

Make sure to replace $USER and $PASS with your Bitbucket username and password!

If you add this to your ~/.bashrc file, you can use this function like this:

bitbucket-repo-create test1

You will see a JSON response indicating whether the operation was successful.

Published inDevelopment