Skip to content

Instantly share code, notes, and snippets.

@sebastianha
Last active December 2, 2019 10:52
Show Gist options
  • Save sebastianha/9358027f5adc646fa848545811b71eac to your computer and use it in GitHub Desktop.
Save sebastianha/9358027f5adc646fa848545811b71eac to your computer and use it in GitHub Desktop.
Unprotect all Branches in GitLab
#!/bin/bash
API_TOKEN="<TOKEN>"
API_URL="https://gitlab.com/api/v4"
for PROJECT_ID in {1..260}; do
echo "Working on Project: $PROJECT_ID"
for BRANCH in `curl -s --header "PRIVATE-TOKEN: ${API_TOKEN}" "${API_URL}/projects/${PROJECT_ID}/protected_branches" | jq -r ".[]|.name?"`; do
echo $BRANCH
curl -s --request DELETE --header "PRIVATE-TOKEN: ${API_TOKEN}" "${API_URL}/projects/${PROJECT_ID}/protected_branches/${BRANCH}"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment