git push --force main line?

0
Hi. Even though I have the role "SCRUM master" I can't push force   $ git push --force Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) remote: error: denying non-fast-forward refs/heads/main (you should pull first) To https://git.api.mendix.com/b852dae5-6dc5-4b95-a28d-8a994073f3e7.git/ ! [remote rejected] main -> main (non-fast-forward) error: failed to push some refs to 'https://git.api.mendix.com/b852dae5-6dc5-4b95-a28d-8a994073f3e7.git/' is there an option to unprotect the branch so it can be at least deleted and re-created? I tried to find the main branch switch in sprintr in the "Team Server" and the "Settings" sections, but it's not there.
asked
1 answers
0

The info on the page Troubleshooting Repository Size helped us find the semi-documented Repository API call that enables push force for the entire repo. I made a bash script compatible with Git For Windows Credentials Helper that does just that. You can put it into /usr/bin/ and call from any Git Bash session:

#!/bin/bash
#
#
set -e
set -o pipefail

url=$(git config --get-regexp "^remote\..*\.url$" | sed 's,.*\(https://git.api.mendix.com/.*\),\1,;t;d')
MENDIX_TOKEN=$(echo "url=${url:?}" | git credential fill | sed 's,^password=,,;t;d')
appid=$(echo "${url:?}" | sed 's,https://git.api.mendix.com/\(.*\)\..*,\1,;t;d')
echo connecting to repository api...
curl -s -v "https://repository.api.mendix.com/v1/repositories/${appid:?}/enable-force-push" \
        --header "Authorization: MxToken ${MENDIX_TOKEN:?}" \
        --data '' 2>&1 | sed 's/\(.*uthorization:\).*/\1 _omitted_/'

 

answered