azure-devopsazure-repos

How To Delete a Folder in DevOps


I'm trying to delete a folder from the main branch in Azure DevOps. The folder does not appear to be tracked by Git as I do not see it in folder view when I checkout the branch.

However, I try to delete from DevOps, I receive the error:

Pushes to this branch are not permitted; you must use a pull request to update this branch

Delete folder from repo

I tried looking at the Branch policies but I didn't see anything that I could change to allow a "push". I tried creating a Pull Request from Main to Main and it says:

There are no changes to merge between the selected branches.

New pull request

I am new to DevOps and Git. Any assistance is appreciated.


Solution

  • You can try any of the following methods:

    1. The recommended way is create a new branch (e.g., temp) based on the main. Delete the unneeded folders and files. Then create a PR (Pull Request) to merge the changes from the temp branch to main. After completing the merge, you can delete the temp branch. You can directly do this in the Git repository on the web UI of Azure DevOps.

    2. If you have the admin permissions or are the owner of the Git repository, you can open the Security hub of main branch, then set the permission "Bypass policies when pushing" to "Allow" for you. With this permission, you can directly make/push changes to the main branch even if it has branch protect policies set. After deleting the unneeded folders and files from main branch, you can consider re-setting the permission "Bypass policies when pushing" back to "Not set" or "Deny".

      enter image description here