Create new repo on Bitbucket from Git Bash terminal?
https://confluence.atlassian.com/bitbucket/repository-resource-423626331.html
$ curl -X POST -v -u username:password -H "Content-Type: application/json" \
https://api.bitbucket.org/2.0/repositories/teamsinspace/new-repository4 \
-d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'
Here is @hannesr's script tweaked a bit to accept input from prompts:
# startbitbucket - creates remote bitbucket repo and adds it as git remote to cwd
function startbitbucket {
echo 'Username?'
read username
echo 'Password?'
read -s password # -s flag hides password text
echo 'Repo name?'
read reponame
curl --user $username:$password \
https://api.bitbucket.org/1.0/repositories/ \
--data name=$reponame \
--data is_private='true'
git remote add origin [email protected]:$username/$reponame.git
git push -u origin --all
git push -u origin --tags
}
You should place this in your .bashrc
or .bash_aliases
.
You can use the Bitbucket REST API and cURL. For example:
curl --user login:pass https://api.bitbucket.org/1.0/repositories/ \
--data name=REPO_NAME
to create new repository named REPO_NAME
.
See Use the Bitbucket REST APIs for more information.
UPDATE
For Bitbucket V2 specifically, see POST a new repo