Reputation: 1
So, without cloning the repo to a local machine and deleting them there and then committing, is there a way to delete multiple folders without it prompting me to commit these changes one by one?
Haven't been able to find a workaround
Upvotes: 0
Views: 128
Reputation: 5567
Without cloning the repo to a local machine and deleting them there and then committing, is there a way to delete multiple folders without it prompting me to commit these changes one by one?
From the web interface, we can only delete the folders and commit the change one by one.
As a workaround, you can set up a pipeline to run the git command to delete the folders in your required branch and commit then in one commit.
Here is the sample YAML:
trigger:
- none
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
persistCredentials: true
- script: |
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git fetch
git checkout test
rm -rf folder1 TestProject/folder2 TestProject/folder/folder3
git add -A
git commit -m "Remove specific folders"
git push origin test
displayName: 'Delete folders'
In the sample, I deleted the folder1
, TestProject/folder2
and TestProject/folder/folder3
in the test
branch. You can replace the folder paths and the branch name as you need.
Test result:
Please noted that you should give your build service account the Contribute permission to perform this action.
Otherwise, you may get this error: TF401027: You need the Git 'GenericContribute' permission to perform this action. Details: identity 'Build\xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', scope 'repository'.
There are two kinds of the build service account, one is project level named {Project Name} Build Service ({Org Name})
, another is the organization level named Project Collection Build Service ({OrgName})
. You can confirm your build service account referring the document or just search the ID from the error message to find the build service account.
Upvotes: 0