Create a new repo on Bitbucket from the Git Bash terminal?

Is it possible to create a new repository in Bitbucket using the Git command line? I tried the following:

git clone --bare https://username@bitbucket.org/username/new_project.git 

I get this message:

Cloning to the 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 application.

+56
git bitbucket
Dec 09 '12 at 14:50
source share
7 answers

You can use the REST API of Bitbucket and cURL. For example:

 curl --user login:pass https://api.bitbucket.org/1.0/repositories/ \ --data name=REPO_NAME 

to create a new repository named REPO_NAME .

See Using the BitBucket REST APIs for more information .

UPDATE

In particular, for Bitbucket V2 see SEND a new repo

+77
Dec 09
source share

More recently, we can just use bitbucket-cli .

Install it using pip

 pip install bitbucket-cli 

Then create a repo using

 bitbucket create --private --protocol ssh --scm git YOUR_REPO_NAME 

Note that this creates a private git repository, you can use --public for sharing and --scm hg if you use Mercurial. User argument can be added via --username YOUR_USER_NAME .

+32
Oct 29 '13 at
source share

Here is the @hannesr script changed the 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 git@bitbucket.org:$username/$reponame.git git push -u origin --all git push -u origin --tags } 

You should put this in your .bashrc or .bash_aliases .

+9
Sep 09 '14 at 19:47
source share

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" }' 
+6
Nov 11 '15 at 17:38
source share

I made a quick shell script that takes care of creating a local git in the current working directory by executing the "Initial commit" and then creating a bitpack repository (using the Mareks hang method) and then finally doing everything necessary to transfer the initial commit to bit baget.

(note that this is only for private repositories, but it is easy to change as described by Patrick)

Use it as follows:

 fillbucket <user> <password> <reponame> 

The code is at http://bitbucket.org/hannesr/fillbucket

+2
Feb 26 '14 at 13:28
source share

@hannester I forked and slightly modified your script.

You had the wrong remote URL (you left your username in the script). Modified username and password in script file.

And renamed with instructions on how to add to the path:

https://bitbucket.org/oscarmorrison/newgit

0
Aug 12
source share

The top cURL answer didn't work for me, so I ended it in Python with the Bitbucket API . Here's the documentation for calling repository.create () .

Installation:

 pip install bitbucket-api 

Python:

 >>> from bitbucket.bitbucket import Bitbucket >>> bb = Bitbucket(username, password) >>> bb.repository.create('awesome-repo', scm='git', private=True) (True, {u'scm': ...}) 
0
Aug 28 '15 at 6:10
source share



All Articles