Created
September 8, 2020 06:51
-
-
Save louiscklaw/9e3b3c31d8fb485801690ff170b8a424 to your computer and use it in GitHub Desktop.
checkout orphan branch
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
You can do that with a few git commands. Please back up your repo before doing this: | |
First create the new history: | |
`git checkout --orphan new-master` | |
Then create the first commit: | |
`git commit` | |
Then delete the old master branch and any other branches you want to delete: | |
`git branch -D master` | |
Now you can rename new-master to master: | |
``` | |
git checkout -b master | |
git branch -d new-master | |
``` | |
And now you can force push this new branch to GitHub to make GitHub forget the old history as well: | |
`git push -u -f origin master` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment