Created
December 10, 2018 22:26
-
-
Save stucka/2973d0702f05003c5061e57b3df29f70 to your computer and use it in GitHub Desktop.
Burn git to the ground, keep only latest commit, shrink size
This file contains hidden or 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
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