Skip to content
English
  • There are no suggestions because the search field is empty.

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:

  1. In Copia Desktop, click the Current Branch button.
  2. Select New Branch.
  3. Enter a branch name and click Create Branch.
    • Your uncommitted changes will automatically move to the new branch.
  4. After the branch is created, switch back to main.
  5. 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

  1. In Copia Desktop, click the Current Branch button.
  2. Select New Branch.
  3. Enter a branch name and click Create Branch.
    • Your commits will now exist on the new branch.
  4. Switch back to main.
  5. In Copia Desktop, go to:
    • Repository → Open in Windows Terminal
  6. 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.