Skip to content

Instantly share code, notes, and snippets.

@stucka
Created December 10, 2018 22:26
Show Gist options
  • Save stucka/2973d0702f05003c5061e57b3df29f70 to your computer and use it in GitHub Desktop.
Save stucka/2973d0702f05003c5061e57b3df29f70 to your computer and use it in GitHub Desktop.
Burn git to the ground, keep only latest commit, shrink size
Burn git to the ground, keep only latest commit, shrink size:
# Adapted from https://stackoverflow.com/questions/9683279/make-the-current-commit-the-only-initial-commit-in-a-git-repository
git checkout --orphan newBranch
git add -A # Add all files and commit them
git commit
git branch -D master # Deletes the master branch
git branch -m master # Rename the current branch to master
git gc --aggressive --prune=all # remove the old files
git push -u -f origin master # 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