gitgithubgithub-pagesgit-branchgit-branch-sculpting

How can I create a new git branch from the base of the commit tree , which has no commit in common with master branch ? for gh-pages


I want to make a new branch from the base of the master branch, such that the new branch has no commit the same as the master branch.

the new branch will be totally different from the master branch, and never to be merged to master

I want to do this because I want to create a gh-pages branch, to host my site. When I click on choose theme in GitHub settings, it creates such a dream branch. But how to create such a branch from the command line ??


Solution

  • If you want to create a completely empty branch you can use the orphan option of the git command:

    git checkout --orphan gh-pages
    

    Then you can add your commits and push the new branch to the repository. There are still several ways that can be used. They are described here.