- Create a new orphan branch
git checkout --orphan TEMP_BRANCH
- Add all files to the staging area
- Commit the changes with an initial commit message
git commit -m "Initial commit"
- Rename the new branch to "main" (or the branch you want to reset)
- Force push the new branch to the remote repository
⚠️ This will reset the repository to the new branch state while keeping the history of contributions in the GitHub graph. Please note that this action will overwrite the remote repository's history, so make sure you have a backup of the original branch before executing these commands.