SteveC
SteveC

Reputation: 16743

How can you stop a branch being deleted in a pull request?

How can you stop a branch being accidentally deleted in a pull request?

The issue is the "Complete pull request" has got the "Delete dev after merging" check box, and this seems to be checked by default, which may be because I'm the owner of the repos.

Is there someway to disable this for all users?

Upvotes: 17

Views: 29006

Answers (3)

sirbradwick
sirbradwick

Reputation: 81

See this post. You just need to add a policy to the branch, then it cannot be deleted.

Upvotes: 1

AmitG
AmitG

Reputation: 609

I may be a bit late on this thread. I faced this problem and found solution in Azure Dev Ops. While approving you get option to deselect.

enter image description here

Upvotes: -5

Marina Liu
Marina Liu

Reputation: 38096

For now, there is no way to disable the Delete source branch after merging option.

And there is an user voice Disable Delete Branch Checkbox in PR When Branch Policy In Place which suggest similar feature, you can vote and follow up.

The workaround is set branch security for the target branch (dev branch for your situation):

In VSTS Branches Tab -> click button for dev branch -> Branch security -> change Force push (rewrite history, delete branches and tags) as Deny for the users and groups -> Save changes.

enter image description here enter image description here

BTW: Delete source branch after merging option in PR completing window is not checked/selected by default, but based on the last time's setting. Such as if you deselect the option now, when you open the PR completing window next time, the Delete source branch after merging option will be deselected.

Upvotes: 28

Related Questions