Orphan branches

You are now familiar with Git's data model, the DAG. You have seen that objects have a parent. When you create a new branch, the commit is its parent. However, in some situations, it is useful to have a branch with no parent.

One example would be an instance where you have your code base in two separate repositories, but, for some reason, you now want to consolidate it into one. One way is to simply copy the files and add them to one of the repositories, but the disadvantage is that you will lose the histories. The second way is to use an orphan branch that can help you to fetch one repository in another.

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.