Skip to content

Instantly share code, notes, and snippets.

@obatiuk
Created October 7, 2017 22:46
Show Gist options
  • Save obatiuk/a1c5e554a02dc905938c4bad03e327c3 to your computer and use it in GitHub Desktop.
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)
#!/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