Search code examples
githubbitbucketpull-requestgithub-cli

How to open a pull request on github for an improvement in a bitbucket fork?


I cloned a github repository into our Bitbucket account. Similar to https://gist.github.com/sangeeths/9467061.

I fixed a bug in my repository located in bitbucket. I'd like to open a pull request on the original github repository that fixes the bug.

If my fork were located on github, I would simply follow these instructions, but since my fork is on bitbucket, I don't know where to start.

How can I open a pull request from my bitbucket repo to the original github repo ?


Solution

  • You can:

    • clone the original GitHub repository to a different folder
    • add your local BitBucket repo as a remote
    • fetch your fix branch (make sure you fix is done in its own branch, not master)
    • create a PR using the cli/cli GitHub command line interface gh pr create

    That is:

    git clone https://github.com/original/repo
    cd repo
    git remote add bb ../yourLocalBitbucket/repo
    git fetch bb
    git checkout bb/fix
    gh pr create
    

    The gh pr create command will do the work for you:

    When the current branch isn’t fully pushed to a git remote, a prompt will ask where to push the branch and offer an option to fork the base repository.