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

How to prevent remote merges of PR's when merging another PR

Hi there,

Our team has recently implemented a gitflow strategy for managing our code base. In simple terms, the strategy is

  1. Create feature branch from develop branch
  2. Checkout feature branch to local copy
  3. Development fase
  4. Git add <changes>
  5. Git commit -m "Message"
  6. Git pull origin feature/branch
  7. Git push origin feature/branch
  8. Git checkout develop
  9. Git pull origin develop
  10. Git merge feature/branch
  11. Git push origin develop
  12. Developer creates PR to release branch and awaits for approval

As you can imagine, after a while, theres a set of Open PR's in BitBucket to be merged into release branch. Each related to different feature branches.

Then, one developer, due to a hotfix, for instance, merges a specific feature branch to that release branch and some of the previous PRs get merged also with the message that <developer> remotely merged <feature> into <release>. 

And that's not really the intention here. We should be able to merge ONLY the specific branch intended to.

Can you please assist in what are we doing wrong?

Many thanks.

1 answer

0 votes
Hana Kučerová Community Leader Jan 18, 2021

Hi @jploureiro ,

welcome to the Atlassian Community!

I would suggest you change the way how you handle hotfixes - process them differently using another branch like is described here - basically create hotfix/xxx branch from the master branch and merge there the changes (if you want to do the code review, use pull request). Then merge the hotfix branch to master and develop.

Hi Hana, 

Thank you for the reply.

That's exactly what we're doing. We're creating a hotfix/xxx branch from master. The problem occurs when we have to merge this branch back into the infinite branches (develop and quality). 

The issue here is not with the hotfixes. It was just an example. Even feature branches, when we try to merge one specific branch into 'quality', some of the open PR's are remotely merged as well. This is the problem.

Thanks again.

Hana Kučerová Community Leader Jan 19, 2021

Hi @jploureiro ,

sorry for the misunderstanding. What you describe is really strange behavior. I believe the auto merge happens, if all the commits from the pull request are also in the merged pull request. Is it possible there are some dependencies between feature branches? It would be great, if you could somehow share commits to be able to see all the history of involved branches...

Is there any specific reason why you are creating pull requests to the release branch? Usually it is done against the develop branch and then everything from develop is released.

Hi Hana,

No problem, thank you for the reply.

I'm not quite sure if I fully understand what you mean but I'll try to respond. For instance, when you say "if all the commits from the pull request are also in the merged pull request", how could one commit be in 2 different pull requests? What we usually do is only one commit per feature branch and, when done, immediately create a PR to the release branch.

Another thing "Is it possible there are some dependencies between feature branches". I don't think so. Every developer updates the same code base in each feature but I don't think that is creating a dependency. 

How can I share the commits with you?

We also merge every feature branch to develop, but we need the release branch because we can not release everything in develop since there's work in progress that can not be released just yet.

Sorry for all the doubts but this process is relatively new for the team.

Thanks again. 

Hana Kučerová Community Leader Jan 20, 2021

Hi @jploureiro ,

thank you.

"how could one commit be in 2 different pull requests?" It is possible, for example if one feature branch is created from the second feature branch, when there are already some commits. That's why I've asked about the branches dependency. But it doesn't seem to be your use case.

If your create some blank test repository - are you able to reproduce this behavior?

Maybe if you can share commit graph for all involved branches, it would help determine, where the problem could be.

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,821 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