Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Preventing changes to specific file/line/variable


I need to prevent merging to a specific branch any pull requests that include a change to a specific Python variable.

Is it possible to do this? Maybe just for a specific line or a specific file? Or maybe instead of preventing the merge, add an alert? 


2 answers

0 votes

It may be a bit heavyweight for your use case, but you could:

  1. Create a commit policy with the Changed paths (files) must match a pattern condition. It will reject changes made on the configured set of files. (It will not check the content of the file though.)
  2. Install it as a local pre-commit hook to every developer's local clone.

That way, developers won't be able to create a commit to that file, so this approach catches the problem early on.

(Disclaimer: this solution requires a paid Jira app that I'm working on.)


0 votes

The best option to stop a PR merge under a certain condition would be to create a configurable merge-check. The merge-check would scan the change set in the source branch and detect any condition you configure.

Unfortunately this is not possible with bitbucket cloud branch permissions - however there is an existing feature request that would allow you to create such a merge-check. Please vote and add yourself as a watcher.

Best, Ulrich

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,239 views 2 9
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you