Delete Git Branches in Azure that are Protected by Branch Policies

We use Git feature branches that are protected by policies that force deletion to occur via Pull Requests. I want an easy way to delete them after a squash commit. This is the best way I found. Of course it assumes you have permission to make the required change.

Step 1: Change your permissions

  • Select the Project in Azure DevOps
  • Open the Project Settings tab
  • Open the Repos/Repositories tab
  • Select the specific repository
  • Select the Security tab (on the right)
  • Select your User account
  • Set the “Bypass policies when pushing” to “Allowed”

Step 2: Delete branch

  • Go to Branches page for repo and delete branch.

Step 3: Restore original permissions

  • Revert any changes made in Step 1.