---
title: Fixing Accidental Changes on a Protected Branch
description: How do you resolve the issue when you accidentally make a changes or commits to a branch with protections enabled
---

[Skip to content](https://help.copia.io/knowledge/fixing-accidental-changes-on-a-protected-branch#main-content)

English

Show submenu for translations

[More support](https://help.copia.io/knowledge/kb-tickets/new?hsLang=en)

![](https://help.copia.io/hubfs/Logo_Hotdog_BlackWhite%20(1).svg)

Open main navigation

Close main navigation

- English
  
  Show submenu for translations
- [More support](https://help.copia.io/knowledge/kb-tickets/new)
- Contact us

 Contact us

 How can we help you?

- There are no suggestions because the search field is empty.

1. [Copia Help Center](https://help.copia.io/knowledge?hsLang=en)
2. [Source Control FAQ](https://help.copia.io/knowledge/source-control-faq?hsLang=en)
3. [Source Control](https://help.copia.io/knowledge/source-control-faq?hsLang=en#source-control)

# 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.*

- [Getting Started](https://help.copia.io/knowledge/getting-started?hsLang=en#main-content)

    - [Sales Wiki](https://help.copia.io/knowledge/getting-started?hsLang=en#sales-wiki)
    - [Account Management](https://help.copia.io/knowledge/getting-started?hsLang=en#account-management)
    - [Customer Experience](https://help.copia.io/knowledge/getting-started?hsLang=en#customer-experience)
- [Source Control FAQ](https://help.copia.io/knowledge/source-control-faq?hsLang=en#main-content)

    - [Web App](https://help.copia.io/knowledge/source-control-faq?hsLang=en#web-app)
    - [Git Questions](https://help.copia.io/knowledge/source-control-faq?hsLang=en#git-questions)
    - [Desktop App](https://help.copia.io/knowledge/source-control-faq?hsLang=en#desktop-app)
    - [Tutorials](https://help.copia.io/knowledge/source-control-faq?hsLang=en#tutorials)
    - [Best Practices](https://help.copia.io/knowledge/source-control-faq?hsLang=en#best-practices)
    - [Source Control](https://help.copia.io/knowledge/source-control-faq?hsLang=en#source-control)
- [DeviceLink FAQ](https://help.copia.io/knowledge/devicelink-faq?hsLang=en#main-content)

    - [Siemens TIA Portal](https://help.copia.io/knowledge/devicelink-faq?hsLang=en#siemens-tia-portal)
    - [Agent](https://help.copia.io/knowledge/devicelink-faq?hsLang=en#agent)
    - [General](https://help.copia.io/knowledge/devicelink-faq?hsLang=en#general)
    - [Rockwell Studio 5000](https://help.copia.io/knowledge/devicelink-faq?hsLang=en#rockwell-studio-5000)

[![Chill listening crop-3](https://help.copia.io/hs-fs/hubfs/Logo_Hotdog_BlackTeal-1.png?width=87&height=24&name=Logo_Hotdog_BlackTeal-1.png "Chill listening crop-3")](http://copia.io)

43 W 24th St, 6th Floor  
New York, NY 10010

<https://www.facebook.com/> <https://www.twitter.com/> <https://www.instagram.com/> <https://podcasts.apple.com/> [mailto:email@email.com](mailto:email@email.com)

Copyright © 2025, Copia Automation, Inc.