0

I have a project with a git repository and the history intact in my local folder. I want to upload this project along with the git repo into the bitbucket server. But I don't want to create the repo in the bitbucket manually. Can I follow the below steps to automatically create repos in bitbucket:

git remote add origin https://User@bitbucket.ad.local/scm/proj1/repos1.git 
  (bitbucket server url without creating repos)
git clone C:\repos1.get https://User@bitbucket.ad.local/scm/proj1/repos1.git
  (cloning the BB repo to my local)
unzip my project folder into this location
git add 
git push -u origin master

These are the steps. Will these steps automatically create a repo in BB? I am aware of using API to create repo. But wondering if these 'reverse' steps will work.

Rick
  • 1,392
  • 1
  • 21
  • 52
  • 2
    No, BitBucket requires you to create a repo using the Website/API first. Besides, you wouldn't need the `clone` step. GitLab allows you to create a repo that way for example. – alfunx Jun 03 '19 at 19:14
  • 2
    Just what @alfunx commented, this is as Bitbucket needs a project for the git repository first. And git clone clones into a local directory, only, so no idea where you obtained that git clone command line from, it does not look right. see as well https://git-scm.com/docs/git-clone (and https://confluence.atlassian.com/bitbucket/create-a-git-repository-759857290.html). – hakre Jun 03 '19 at 19:19
  • 2
    Possible duplicate of [How to create repository on BitBucket remotely?](https://stackoverflow.com/questions/3129165/how-to-create-repository-on-bitbucket-remotely) – wjandrea Jun 03 '19 at 19:44

1 Answers1

0

If you don't wish to create it manually create it using a script:

Create Project

# Create Project
curl -u <username>:<password> \
  -X POST http://<bitbucketIP>:7990/rest/api/1.0/projects \
  -H "Content-Type: application/json" \
  -d @- << EOF
  { "key":"<project key>", 
    "name":"<project name>"
  }
EOF

Create repositories

# Create repositories
curl -u <username>:<password> \
  -X POST http://<bitbucketIP>:7990/rest/api/1.0/projects/<project name>/repos   \
  -H "Content-Type: application/json" \
  -d @- << EOF
     { "slug": "<project name>", 
        "name": "<project name>", 
         "scmId": "git", 
         "project": { 
             "key": "<Project name from prevoius step>"
         }
     }
EOF

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167