4

Is there a git command to create a Pull Request directly on Bitbucket when pushing a Branch?

Or any other way to create Pull Request on Bitbucket directly from the command line or PHP

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
Esnare Maussa
  • 51
  • 1
  • 8
  • `git` doesn't have things like pull requests, so that's the wrong place to look for such a feature. However, there are git extensions that may help to integrate with other systems like Bitbucket's. – Ulrich Eckhardt Aug 30 '18 at 05:56
  • 1
    Possible duplicate of [Bitbucket: Send a pull request via command line?](https://stackoverflow.com/questions/8721730/bitbucket-send-a-pull-request-via-command-line) – phd Aug 30 '18 at 12:02
  • https://stackoverflow.com/search?q=%5Bbitbucket%5D+command+line+pull+request – phd Aug 30 '18 at 12:02

2 Answers2

4

You could use the BitBucket API and POST the right command, as in this thread:

POST /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests

That is:

curl -u user:myPW -H "Content-Type: application/jso https://bitbucket.server.com/rest/api/1.0/projects/myProject/repos/myRepo/pull-requests -X POST --data @req.json

with data:

{"title":"test","description":"test","fromRef":{"id":"refs/heads/test-branch","repository":{"slug":"test-repo","name":null,"project":{"key":"myProject"}}},"toRef":{"id":"refs/heads/master","repository":{"slug":"myRepo","name":null,"project":{"key":"MyProj"}}}}
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

You can use Bitbucket pull requests API via curl as it:

curl https://api.bitbucket.org/2.0/repositories/my-username/my-repository/pullrequests \
-u my-username:my-password \
--request POST \
--header 'Content-Type: application/json' \
--data '{
    "title": "My Title",
    "source": {
        "branch": {
            "name": "staging"
        }
    }
}'
Mehdi Chaouch
  • 425
  • 4
  • 7