Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git root branches... how do they work?

I was reading up on http://pages.github.com/ and one thing caught my eye:

If you create a new root branch named gh-pages in your repository, any content pushed there will be published to [url]

I searched everywhere for information about root branches, but there don't seem to be many resources on this. Does anybody know how to best explain what root branches are?

My current understanding is that if there are two root branches, they essentially represent two 'repositories' within one repository. Is this accurate?

like image 607
Scott Frazer Avatar asked Feb 03 '23 07:02

Scott Frazer


1 Answers

The steps given in the link you mentioned tell you how to create one:

$ cd /path/to/fancypants
$ git symbolic-ref HEAD refs/heads/gh-pages
$ rm .git/index
$ git clean -fdx

A root branch is basically a "branch" that is started as an orphan and has no previous history. While every repo starts with a master and the branches are branched off from that, a root branch will not be branched off from master ( of course there are repos with no master, renamed master etc, but master is the common case) and have its own history. Conceptually, yes, it is like two repos in a repo.

In the above steps, the gh-pages is created as a root branch.

Also see my answer here: How do I create a commit without a parent in Git?

like image 114
manojlds Avatar answered Feb 05 '23 15:02

manojlds