I'm getting ready to start version 2.0 of a library, a complete rewrite. I'll basically start from scratch, but I'd like to keep working within the same Git repository. I'm trying to figure out how to approach creating a clean new brach for the rewrite.
The naive way to start would be to create a new branch, and delete everything:
$ git checkout -b v2
Switched to a new branch 'v2'
$ rm -rf *
$ git commit -m "empty the branch for a clean slate"
$ git push origin v2
However, it's not ideal to have this commit that deletes everything in the branch. I'd like to be able to create a new empty branch, while keeping the commit history.
It seems like git checkout --orphan v2 will create a new empty branch, but it also has no parent.
Is there another way to create a clean empty branch without losing commit history?
Your history will always be in the v1 branch. Ie master. When v2 becomes stable you can make that master and rename the old master to v1
Orphan is the best way way to start fresh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With