Created
January 29, 2024 16:24
-
-
Save NobsterDev/108e114d4abced855dd1554badf169c7 to your computer and use it in GitHub Desktop.
Deleting history on a repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a new orphan branch (unrelated to the current branches) | |
git checkout --orphan new_branch | |
# Add all files to the new branch | |
git add -A | |
# Make the initial commit | |
git commit -m "Initial commit" | |
# Delete the old main branch locally (replace 'main' with your branch name) | |
git branch -D main | |
# Rename the new_branch to main | |
git branch -m main | |
# Push the new main branch to the remote repository (Ensure your remote branch is not protected or allowed to force push) | |
git push origin main --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment