Best practice repository setup to allow contractor access

Hello, sorry if my terminology isn't accurate, I'm used to using SVN and still learning Bitbucket.

We use in-house and outsourced developers. The in-house developers currently have read/write access to the trunk (master branch?). I would like to know the best way to allow our outsourced developers to read/write to our repository, while protecting ourselves against bad code being committed. My first thought was to give them read access to the trunk so they could always pull down the latest code, and create a new branch for them to commit to. Then, I could review their branch commits and merge them into the trunk.

Would that be an ideal approach, or is there a better option? Thanks!

1 answer

That is the correct approach, but to boil it down to the very essentials, the primary goal here will be preventing un-reviewed code from being pushed to specific branch(es), and that part is actually really straightforward.

The post at provide an introduction to the Branch Restrictions feature, that will prevent unauthorized changes to branches. Use this to ensure that only trusted people can merge changes.

Next, ask your outside developers to do all work on new branches, creating a different new branch for each topic of work, such as a specific bug or feature. When they feel their work is complete and ready to merge, they would file a Pull Request and add reviewers that are trusted to modify the protected branches. When the reviewers are satisfied that the changes are consistent with your code guidelines, they can "approve" to signal that this is confirmed, or "merge" to introduce it to another branch. If there are concerns, the reviewers can make comments directly against the pull request, or against individual lines in the "diff" to guide the submitter to make changes.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

692 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot