> I accidentally made changes on `main/dev` instead of creating a new branch. What do I do? #### Check the changes Commit the changes temporarily: ```bash git add . git commit -m "Temporary commit on main" ``` Stash the changes: ```bash git stash ``` #### Create a new branch from `main`: ```bash git checkout -b new-branch-name ``` #### Bring the changes onto the new branch If the changes were committed: - First, get the commit hash of your last commit on `main` (or the specific commit you want to move): ```bash git log ``` Then, **cherry-pick** that commit onto the new branch: ```bash git cherry-pick <commit-hash> ``` If the changes were stashed your changes earlier, simply **pop** the stash: ``` git stash pop ``` #### Reset `main` to its previous state Now, remove the changes from `main` itself. It can be reset to the last commit where `main` was before the changes: ```bash git checkout main git reset --hard HEAD~1 # Change 1 to however many commits on main need to be removed ``` This will remove the commit(s) from `main`, effectively "undoing" thte changes on that branch. **Note:** If more than one commit was made and multiple need to be undone, adjust the `HEAD~1` part accordingly (e.g., `HEAD~2`, `HEAD~3`). #### Push the changes (optional) ```bash git push origin main --force ```