Last active
December 28, 2015 19:19
-
-
Save stash/7549624 to your computer and use it in GitHub Desktop.
Rebasing onto a new initial commit
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
| git checkout master | |
| git checkout -b rebaser | |
| git checkout master | |
| git update-ref -d refs/heads/master | |
| git rm -rf $EVERYTHING_EXCEPT_GITIGNORE # figuratively | |
| git commit -m 'initial commit' | |
| # this will remove the commits off of the remote (to be GC'd at some indeterminate point) | |
| git push --force origin master | |
| # now, rebase onto this new, sparse, initial commit | |
| git checkout rebaser | |
| git rebase master # use -i to reword the formerly-initial commit | |
| # assuming you want to make a PR | |
| git push -u origin rebaser | |
| # then, if you want to bring it all back | |
| git checkout master | |
| git reset --hard rebaser | |
| git push --force origin master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment