Skip to content

Instantly share code, notes, and snippets.

@NobsterDev
Created January 29, 2024 16:24
Show Gist options
  • Save NobsterDev/108e114d4abced855dd1554badf169c7 to your computer and use it in GitHub Desktop.
Save NobsterDev/108e114d4abced855dd1554badf169c7 to your computer and use it in GitHub Desktop.
Deleting history on a repo
# 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