Skip to content

Instantly share code, notes, and snippets.

@louiscklaw
Created September 8, 2020 06:51
Show Gist options
  • Save louiscklaw/9e3b3c31d8fb485801690ff170b8a424 to your computer and use it in GitHub Desktop.
Save louiscklaw/9e3b3c31d8fb485801690ff170b8a424 to your computer and use it in GitHub Desktop.
checkout orphan branch
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