简体   繁体   中英

Creating bitbucket repository using Git bash

I am trying to create a bitbucket repository through git bash and I am suing Curl command as below:

$ curl -k -X POST -v -u username:xxxxx -H "Content-Type: application/json" \
  https://bitbucket.org.local/projects/proj1/repos/repotest \
  -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'

Upon running this command, I am getting invalid credential error and the output looks like below: 在此处输入图片说明

My credentials are correct but I am unable to create the repository. Any help?!!

You can try using bitbucket-cli.

First, 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 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.

Although pcampana's answer is correct and you could use python and pip, I was checking what could be wrong with the curl command. And I guess you are missing the rest path in the url and the name of the repository should be in the post data. ( https://docs.atlassian.com/bitbucket-server/rest/6.3.1/bitbucket-rest.html#idp152 )

I guess, the missing rest/api/1.0 in the url makes the server think that you want to reach a "normal" webpage for which Basic Authentication seems to not be possible.

So try:

curl -k -X POST -v \
    -u username:xxxxx \
    -H "Content-Type: application/json" \
    https://bitbucket.org.local/rest/api/1.0/projects/proj1/repos \
    -d '{"name": "repotest", "scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM