Azure-devops-docs: Policy to require source branch to be deleted when squash merging

Created on 17 Dec 2018  ·  11Comments  ·  Source: MicrosoftDocs/azure-devops-docs

I've seen lots of branches left over after merges are complete, including after a squash merge. It would be really nice to be able set a policy that if you squash merge a PR, then the source branch is automatically deleted.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 devops-code-gitech devopprod product-feedback

Most helpful comment

Correct, I am wanting a rule to always force branch deletion after PR completion.

All 11 comments

@bartsipes You can check the box to delete the source branch as part of completing the PR (when you complete your own PR on the branch you created), but if someone else completes your PR they don't have that option. Am I misunderstanding your question, it sounds like we may already have the capability to do what you are asking. Can you provide more details for your scenari?

@steved0x bartsipes is not asking how he can do it, he's asking for a branch policy to ensure that it _always_ happens.

Correct, I am wanting a rule to always force branch deletion after PR completion.

And vice-versa, I'd really appreciate being able to disallow squash merges into some branches. We have dev and master branches that are long lived, and when someone squashes the merge in a PR between the branches it makes a horrible mess because they can't delete the source branch.

Agreed @nickfoster just came here to work out if that was possible!

Joined GitHub just to thumbs up this request. The fact that VSTS makes it easy to rebase a pull request without deleting the source branch has caused our team headaches in the past despite educating people on best practices. Mistakes happen. A policy that enforces "_Cannot squash unless you have permission to delete the source branch, and squashing deletes the source branch_" would be fantastic.

Thanks for the suggestion! To make sure it gets in front of the product team for triage, please submit your idea here.

https://developercommunity.visualstudio.com/idea/767668/pull-request-global-policy-only-allow-squashrebase.html Created a new feature suggestion, since older ones somehow got closed as fixed.

@janderson-connectwise thank you! (I voted up alredy 👍 )

I like this idea, but you'll need to take care for cases where submodules are being merged. Squash-merging AND deleting source branches is dangerous thusly: If you squash-merge the submodule, there end up 2 new commits to the target branch, the squash one and the merge one. If you also delete the source branch, you're also deleting the commits made on that branch, so unless you take care to update it, the superrepo will be pointing to a non-existing commit!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cijujoseph picture cijujoseph  ·  3Comments

dannyvv picture dannyvv  ·  3Comments

atrauzzi picture atrauzzi  ·  3Comments

KacperMucha picture KacperMucha  ·  3Comments

MJECloud picture MJECloud  ·  3Comments