Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can I disable re-writing a branch history if and only if a PR is open against a branch?

my company used BitBucket Cloud.


I know that I can configure branch permissions to disable re-writing history based on a regex-list pattern.


Screen Shot 2018-07-19 at 3.00.21 PM.png

However, I want to allow the developers to rewrite branch history to their hearts content, and prevent it if, and only if, that branch is the source branch of a Pull Request.  We have Merge check configure to not merge if there are open bitbucket tasks against the PR.

Here's the workflow:

User #1.

  • Create a branch on the remote server.
  • Commit, commit, commit and push
  • Commit, push
  • Perform interactive rebase and squash all commit into a single one.  git push
  • Create a PR and add user #2

User #2:

  • Open PR.  
  • Adds a few BitBucket tasks and approves

User #1:

  • Addresses the comments.  Does it git commit
  • Before pushing an update, does a git rebase and update the branch history  <<< I want this to fail because a PR is open againt the branch
  • Pushes the changes

User #2:

  • Received an notification PR has been updated. 
  • Opens the PR and goes to the "Activity" tab.
  • Search for the "User #1 approved" message and select the "See what's changed link"
    Screen Shot 2018-07-19 at 3.09.54 PM.png
  • User freaks out because the diff shows code changes unrelated to the "fix"

When this happens, the commit that was approved no longer appears in the PR "commits" view.


Is it possible to disable rewriting the branch history if, and only if, a branch has an open PR against it?

1 answer

I want this functionality as well.  

Suggest an answer

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

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,757 views 10 16
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