Hi,
I am new to Bitbucket.
My Admin has created a new Project PRS. It's path is like http://server:port/projects/PRS. He said I can now be able to add code.
I need to create a Repository / folders like QA & PROD and add code in it. Could you please guide me in simple steps either through Git CMD or Git UI?
Thanks in advance.
David
Hi David!
You can find step by step instructions on how to create a repository using the Bitbucket UI at Creating repositories. If you prefer to do it through the Git CMD, you can read Setting up a repository.
Once you've done that, you'll start coding. In this other article you'll learn how to get started with Git and Bitbucket and how to push your code to Bitbucket, visit Getting started with Git and Bitbucket Server.
Also, if you'd like to use a Git client, you can install Sourcetree which is free and available for Mac and Windows.
I hope this helps, David. Let me know if you have any questions!
Cheers,
Ana
Hi Ana!
Thank you very much! I will follow the steps.
I have a question : I dont see the option "Create Repository" from UI. Can I be able to create a repository with command line? ( assuming I dont have Project Admin Rights)
Thank you,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David, when you click Repositories in the navigation bar, a menu will be displayed and you'll see your recent repos and the option to create a new one. If you can not see the Repositories button, you'll need to check with your admin if you have the right permissions. If you still don't see it, you can send a screenshot of what you see in your Bitbucket UI (remember to remove any sensitive information ;) )
If you prefer to do it via command line, you can use:
git init <directory>
That will create an empty Git repository in the specified directory. You can find more info at Setting up a repository.
Were you able to create a repository now?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ana, Thanks for the reply.
I have followed up with my Admin to provide "Project Admin" access. Now, I am able to see the option and able to create the Repository.
Before "Project Admin" access is given to me, I have tried using Command line but unable to doit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there a simple way to create a repo on the bitbucket server (self hosted) using the git (bash) shell script? I want to split folders into single repos and create those from a script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think the answer shouldn't have been accepted as a solution, since it is not done from the cli. Git init creates a local git folder, doesn't create a remote on bitbucket.
It is hard to create a repo on bitbucket and then clone it and then copy the application files over. I don't see how is this called convenient. There should be a way similar to github, to create and then connect the repo to an existing project, and that should be a copy-paste similar to github new repo site. If something is working I don't see why change it.
git init .
git remote add origin <repourl>
git add .
git commit -m "Initial commit"
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've been using this but the APIs are suddenly deprecated.
Does anyone have an alternative? I miss it so much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Email the owner Zhehao and ask him to update it OR open source it https://pypi.org/project/bitbucket-cli/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This API is no longer supported.\n\nFor information about its removal, please refer to the deprecation notice at: https://developer.atlassian.com/cloud/bitbucket/deprecation-notice-v1-apis/"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Request Error 410: gone
{"type": "error", "error": {"message": "Resource removed", "detail": "This API is no longer supported.\n\nFor information about its removal, please refer to the deprecation notice at: https://developer.atlassian.com/cloud/bitbucket/deprecation-notice-v1-apis/"}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any news on this?
As a community, maybe we can together take over the project and update to new API version?
At least just for creating a new repo.
What do you say?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe that the problem is that the new API on the backend does not support this functionality.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please share.
I would love to get together but I am no where near good enough to contribute having only just started using git never mind learning how apis work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
curl -X POST -u your_username:access_token_or_app_password -H 'Content-Type: application/json' https://api.bitbucket.org/2.0/teams/your_team_name/projects/ -d '{"name": "ABC Project", "key": "ABC", "description": "ABC project description", "is_private": true}' | jq .
curl -X POST -u your_username:access_token_or_app_password -H 'Content-Type: application/json' https://api.bitbucket.org/2.0/repositories/team_name_or_username/repo_name -d '{"is_private": true, "scm": "git", "project": {"key": "ABC"}}' | jq .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to describe these two above: the first creates a project, and the second creates a repo inside that project.
Also, in the second one, you're telling bitbucket the URL that you would like it to be available at, and it doesn't matter that the "repo_name" endpoint doesn't exist yet.
If you don't have jq installed you can omit the "| jq ." bit at the end; it just deciphers the response.
Lastly, if you're not using a team, you may need to edit the first URL slightly - see the API documentation
If you're not using projects, omit the first request, and remove the "project: {"key": "xyz"}," part in the json in the second request.
I used the Postmaster app to help me formulate and reuse these calls.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for that.
I'm struggling with this, could you help me a little more please.
I'm a solo designer, I don't work with teams at the moment but I have setup a team to try and get this to work.
I'm currently using your second piece of code minus a few bit as mentioned in your description. See below:
curl -X POST -u myusername:123456789 -H 'Content-Type: application/json' https://api.bitbucket.org/2.0/repositories/myteam/repo_name -d '{"is_private": true, "scm": "git"}'
When I paste that code into MacOS Terminal and nothing happens. I check Bitbucket after and nothing has been added.
To setup my API (OAuth) I just gave it a name, ticked all permissions but I thought this was enough to get it to work.
What am I doing wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, you're doing great! You've written it correctly -- actually you don't need a team if it's just yourself, you could replace the team name with your username -- but if you're getting no response then it probably doesn't like the key you're giving it. I just tested and if I mistyped the key I received no response at all.
I'm very sorry but I gave the wrong info before. It's not an API key that's needed here, but an authorisation token - that's a complicated thing to produce for this purpose so in its place you can use an app password.
Go to your bitbucket settings, click App Password (under Access Management) and create a new app password - call it command line API or whatever you like. You can use this password in your API requests.
Hope that helps, sorry about the misinformation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you're going to do this a lot, and are using a unix-based system like macos or linux, you can install jq (with homebrew it's `brew install jq`) to make the output more readable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you
Installed an app password and it now works for both teams and as a solo repo.
I've also installed jq which helps.
Thank you for your help.
P.S Is there a way to delete a repo using the same way?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looks like you guys liked only curl idea, which is probably the perfect solution for the start. Do you think we need to expand it to a CLI client? If yes, what would be the prefered way for you to use it and to install it (pip, npm -g, composer --global, brew)?
We need to explain also how to authenticate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey guys this is not working for me. i am getting this:
{
"type": "error",
"error": {
"message": "Forbidden"
}
}
but in the AppPassword i can see my access.
i can use the GET method as in
curl -X GET -u MyUSER:$ADMIN_TOKEN -H 'Content-Type: application/json' https://api.bitbucket.org/2.0/teams/MyUSER/projects/ | jq .
Please help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.