Adrian
Adrian

Reputation: 10911

Are there any issues having multiple root nodes in Git?

I've just been introduced to orphan nodes in Git and I was wondering what sort of potential problems I could expect with using them?

Upvotes: 6

Views: 2806

Answers (3)

Mark Adelsberger
Mark Adelsberger

Reputation: 45779

If you at some point need to merge across the branches, you'll have to use the --allow-unrelated-histories option; but it's literally as easy as adding that option to the merge command, and if you omit it git will tell you exactly what you'd need to do.

So if that counts as an issue, there's that. Otherwise, whether you have independent roots in your repo doesn't really affect much of anything functionally.

Upvotes: 5

larsks
larsks

Reputation: 312263

The subject of this question ("...multiple root nodes...") makes me suspect that you and @raina77ow are actually using "orphan" to refer to two different things. The thread to which the comments links discusses what are normally called dangling commits, while an "orphan" branch typically means a branch that doesn't share history with other branches in your repository. You can create one like:

git checkout --orphan newbranch

There's nothing inherently wrong with orphan branches. In fact, tools like GitHub Pages rely on orphan branches to manage content.

Upvotes: 9

tkruse
tkruse

Reputation: 10695

It's a common situation as an example when you try to merge the histories of 2 git repositories into one. There is no big issue of having orphaned branches, other than confusion of users.

Upvotes: 2

Related Questions