Git can host multiple DAGs in the same repo with git checkout --orphan
command. A frequently cited use case this feature of git is to keep separate a branch for docs or the GitHub gh-pages
orphaned branch for creating a static website.
Are there other reasons to use orphaned branches in git?
If you want to share your branch with someone else with no history, you can do that by creating an orphan branch. An orphan branch is a separate branch that starts with a different root commit. So the first commit in this branch will be the root of this branch without having any history.
The core use for git checkout --orphan is to create a branch in a git init -like state on a non-new repository. Without this ability, all of your git branches would have a common ancestor, your initial commit. This is a common case, but in no way the only one.
Your commits aren't gone (yet) When you use --force, you are adding new commits to Git and updating the branch reference of your branch. You have only orphaned the existing previous line of work as it is no longer referenced by anything.
Git branch_name Branch is a beauty of git. You can work with coworkers without any interference with them. This will create a local branch with the name branch_name . Then you can switch your branch to this by git checkout branch_name .
Another possible use of this is for combining multiple repositories into one. A few examples:
In these cases you will have two separate DAGs in the same repository before they are merged into a single unified tree. Thus this is not as much a long-term use, but an action that will temporarily pass through the state of having separate DAGs in the same repository.
Another use case by the git
online documentation:
This can be useful when you want to publish the tree from a commit without exposing its full history. You might want to do this to publish an open source branch of a project whose current tree is "clean", but whose full history contains proprietary or otherwise encumbered bits of code.
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