Is it possible to create a new repository in Bitbucket by using command line Git? I have tried the following:
git clone --bare https://username@bitbucket.org/username/new_project.git
I get this message:
Cloning into bare repository 'new_project.git'...
fatal:https://username@bitbucket.org/username/new_project.git/info/refs
not found: did you run git update-server-info on the server?
It would be nice to do this without going to the web app.
More recently, we can just use
bitbucket-cli
.Install it using
pip
Then create a repo using
Note that this creates a private git repo, you can use
--public
for public access and--scm hg
if you use Mercurial. Username argument can be added via--username YOUR_USER_NAME
.You can use the Bitbucket REST API and cURL. For example:
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
I've made a slight modification to @pztrick above script. This new script should work the same, but it uses the newer 2.0 API:
You can place this in your .bashrc or .bash_aliases file (just like the original script).
Note that it will also create this as a private repo. You can change "is_private": "true" to "is_private": "false" to make it a public repo.
https://confluence.atlassian.com/bitbucket/repository-resource-423626331.html
@hannester I forked and slightly modified your script.
You had the incorrect remote url (you left your username in the script). Modified it to included Username and Password in the script file.
And renamed, with instructions on how to add to path:
https://bitbucket.org/oscarmorrison/newgit
The top answer with cURL wasn't working well for me, so I ended up doing it in Python with Bitbucket-API. Here's the documentation on the repository.create() call.
Install:
Python: