Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>> Zero a branch to do something radically different

There's another way to do this:

    git checkout --orphan new-branch


Last time I tried this, I was getting a lot of hassle when switching between branches that have no common ancestor; .gitignored files disappearing completely (very annoying when you keep a local config file around etc.), files left over and "not staged for commit" instead of being removed, etc. Maybe the "empty root commit" trick would help, I haven't tested that they.


You are going to have those issues anyway. Since there is no common ancestor you will have to commit a .gitignore from scratch to that new branch. Files left over is another common issue, if they are not committed then when you switch branches they are going to stick around, just like with any other branch switch...





Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: