Skip to content

Instantly share code, notes, and snippets.

@dcasati
Last active January 3, 2022 16:33
Show Gist options
  • Save dcasati/33f4a807784d8afa9c15b8c0884c0e45 to your computer and use it in GitHub Desktop.
Save dcasati/33f4a807784d8afa9c15b8c0884c0e45 to your computer and use it in GitHub Desktop.
# Use these steps to clear out Github's commit history.
# Useful when moving a repo from private to public
git checkout --orphan newBranch
git add -A # Add all files and commit them
git commit
git branch -D main # Deletes the main branch
git branch -m main # Rename the current branch to main
git push -f origin main # Force push master branch to github
git gc --aggressive --prune=all # remove the old files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment