Created
October 7, 2017 22:46
-
-
Save obatiuk/a1c5e554a02dc905938c4bad03e327c3 to your computer and use it in GitHub Desktop.
Makes current commit in master the only initial commit in git (e.g. deletes all history)
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
#!/bin/sh | |
# Source: https://stackoverflow.com/questions/9683279/make-the-current-commit-the-only-initial-commit-in-a-git-repository/13102849#13102849 | |
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 push -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