Fixing Accidental Changes on a Protected Branch
How do you resolve the issue when you accidentally make changes or commits to a branch with protections enabled
If you accidentally make changes directly on a protected branch (such as main), follow the steps below based on your situation.
Scenario 1 — Changes Made but NOT Committed
Move your uncommitted changes to a new branch and restore main back to a clean state.
Steps:
- In Copia Desktop, click the Current Branch button.
- Select New Branch.
- Enter a branch name and click Create Branch.
- Your uncommitted changes will automatically move to the new branch.
- After the branch is created, switch back to
main. - In Copia Desktop, discard the remaining changes on
main:- Open the Changes tab.
- Right click on the top and select Discard All Changes.
Your changes are now safely on the new branch, and main is clean again.
Scenario 2 — One or More Commits Already Made
Keep your commits by moving them to a new branch, then reset main back to the same as the remote version.
Steps
- In Copia Desktop, click the Current Branch button.
- Select New Branch.
- Enter a branch name and click Create Branch.
- Your commits will now exist on the new branch.
- Switch back to
main. - In Copia Desktop, go to:
- Repository → Open in Windows Terminal
- Run the following command:
git reset --hard origin/main
This resets your local main branch to match the protected remote branch exactly.
Warning: This command permanently removes local commits from
main. Make sure the commits were moved to the new branch first.