Sirop4ik
Sirop4ik

Reputation: 5253

In which case could be useful git checkout --orphan?

I found out that there is a possibility to create an orphan branch git checkout --orphan and as far as I understood this command will create a branch that has no history, but I just trying to think in which case could it be useful? Why do I need to create such kinds of branches?

Upvotes: 0

Views: 335

Answers (1)

iBug
iBug

Reputation: 37267

One example is that when I want to torch the history of a branch, I would create an orphan branch from its current state, and create the root commit for force-pushing.

It's easy to understand why. For example, I use GitHub Actions to deploy my static website onto GitHub Pages, and when there's too many history bloating the repository, I would "reset" the deployment branch and torch its history, since that branch contains solely of program-generated content (the built website).

Upvotes: 1

Related Questions