# Backup your repository before attempting this process as it will remove all commits permanently.
# Step 1: Make sure you are in the root directory of your local Git repository.
# Step 2: Create an orphan branch. This branch will not have any history.
git checkout --orphan new_branch
# Step 3: Add all your files to the newly created branch.
git add -A
# Step 4: Commit the changes with an empty commit message.
git commit --allow-empty -m "Initial empty commit"
# Step 5: Delete the original branch (e.g., `main` or `master`).
git branch -D main
# Step 6: Rename the new branch to the original branch name (e.g., `main` or `master`).
git branch -m main
# Step 7: Push the changes to the remote repository with force. This will overwrite the remote branch.
git push -f origin main