JamesD
JamesD

Reputation: 2546

Create Fork on bitbucket using REST API in a given project

I found Using BitBucket's API to fork a repository and this is helpful in so far as letting me know that creating a fork is possible.

However I want to create the fork in a certain project on the bitbucket server.

We have a use case where we want to create a fork of some repositories in another project and then merge back only the parts of the project that are re-usable not the project specific stuff.

Upvotes: 2

Views: 712

Answers (1)

elbeho
elbeho

Reputation: 71

Assuming you want to fork PRJ1/repo_AA as PRJ2/repo_BB, you can use:

curl -X POST -H 'Content-Type: application/json' \
     -d '{ "slug": "repo_BB", "name": "repo_BB", \
           "project": { "key": "PRJ2" } }'       \
     https://your.serv.er:7990/rest/api/1.1/projects/PRJ1/repo_AA

Be sure project PRJ2 already exists (you can create it via REST API as well) and have the correct credentials.

HTH

Regards

Upvotes: 4

Related Questions