How to configure Sourcetree to perform a pull request with Bitbucket Server

RKadmin September 27, 2018

I have installed an evaluation version of Bitucket Server on a PC on my local network. I have then installed SourceTree on a different PC.  After committing an update on a branch I want to perform a pull request. If I do this within SourceTree it tells me I must configure a remote before it will allow it.

Specifically, it wants the following information.

Required Information:

   Remote name:  ???

   URL/Path: ???

Host Type:

Host Root URL:

Username:

What do I enter for all of this? The URL to the Bitbucket server is: 192.168.1.129:7990

The full URL to the repo is: 192.168.1.129:7990/scm/tp1/repo1.git

I have tried variations of this already and have not had success. Note that if I open a browser and go directly to the BitBucket and create a pull request there, that seems to work fine. Is it possible to do this from within SourceTree?

1 answer

1 accepted

0 votes
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 27, 2018

Hi Randy,

Welcome to the Atlassian Community.

The repository you did your commit in, does it exist on your Bitbucket Server? If not then the first step would be to create it on Bitbucket and then follow the instructions on how to import existing code (your repository on your other machine). Once that is done you set up the extended support in order to initiate pull requests from within Sourcetree by clicking on Settings, select the remote repository path, select edit and from here you can enter the host type, host root URL and username.

RKadmin September 27, 2018

Yes, the repository does indeed exist. I can do pushes and pulls with no problem (with all branch permissions removed). 

My question is what exactly do you put in those fields that I have listed in BOLD in my original post? Is "Remote Name" arbitrary or does it correspond to something configured in the BitBucket server setup? What specifically would you enter into URL/Path? As mentioned, the link to the server is:

http://192.168.1.129:7990

The full path to the repository is:

http://192.168.1.129:7990/scm/tp1/repo1   (where tp1 is the name of the project and repo1 the name of the repository)

Curiously, for "host type" the WIN10 version of SourceTree does not provide an option for "BitBucket Server" while the MAC version does. 

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 27, 2018

In Sourcetree, in the tab for your repository click on Settings in the upper right-hand corner. From here select the remote repository path (origin by default) and then select Edit. From here you can enter the Host Root URL (http://192.168.1.129:7990) and your username.Sourcetree.png

Yes, on Sourcetree Windows the host type is Stash for Bitbucket Server, which is the old name before Atlassian renamed it to Bitbucket Server. 

Like Nathaniel Rink likes this
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 27, 2018

For your reference, here is the Bug logged about the host type still being Stash, SRCTREEWIN-7725

RKadmin September 27, 2018

This is what I entered:

Where "rk-dev2" is the user name on the PC trying to create the pull request from SourceTree.Capture.PNG

Let me know if you see anything you think is incorrect.

If I then attempt to Create Pull Request, I get a dialog with these three settings:

Submit via remote: origin: http://192.168.1.129:7990

Local branch: master

Remote branch: master

These appear to look correct to me. Again let me know if you would change anything.

Then when I hit the "Create Pull Request On Web" button I get the red FAIL bar with a message that states:

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks push -v --tags --set-upstream origin master:master
POST git-receive-pack (201 bytes)

remote: ----------------------------------------------------
remote: Branch refs/heads/master can only be modified through pull requests.
remote: Check your branch permissions configuration with the project administrator.
remote: ----------------------------------------------------

Pushing to http://192.168.1.129:7990/scm/tp1/repo1.git
To http://192.168.1.129:7990/scm/tp1/repo1.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://192.168.1.129:7990/scm/tp1/repo1.git'

Completed with errors, see above.

I feel like I am close but something is amiss. I appreciate the help!

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 27, 2018

Did you do your commit on master? The error indicate that you did and on Bitbucket it is setup to not allow any commits without a pull request. If that is the case, the easiest way to solve it is to locally create a new branch on your commit, push that new branch up and then create a pull request from the new branch to master.

RKadmin September 27, 2018

This may be a clue. 

I noticed that an option under the "Remote branch" is the name of the branch I am attempting to merge to the master on the server. In this case, does "Remote branch" refer to the branch on the local PC or the server? If I change it to the name of the development branch, the server then seems to accept the request including opening up a browser so the process can be completed in a Bitbucket browser page.

Perhaps my confusion is that, in this case, the remote branch refers to the non-server machine. IE: The PC trying to perform the pull request via SourceTree. 

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 27, 2018

Remote branch refers to the branch that your local branch is tracking/is a copy of. You can change it to a different branch, so you can push your local changes to a different branch.

RKadmin September 27, 2018

I think your last statement gets to the heart of the issue. When using SourceTree to perform a pull request (for an eventual merge to the server master), the name of the branch you are pushing cannot be one's local master. It must be named something else. This looks like it can be done before or after the local commit but I believe it is better practice to create the branch before you start the local development. Once the (alternatively named) branch is pushed to the master, it will be merged after the pull request is approved.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events