How to create a clean branch without taking the master branch history?

2

I need to create a clean branch that does not reflect the commits of the master branch. This branch will be used to make project information available on Github through gh-pages and will never be used to merge with the master branch.

    
asked by anonymous 13.09.2015 / 02:29

1 answer

3

First create an orphan branch:

git checkout --orphan gh-pages

Now remove all files from this branch:

git rm -rf .
git clean -fdx

Add some file, for example README.md :

touch README.md
git add .
git commit "chore(app): initial commit"

Now just push the server:

git push origin gh-pages

Check out the master and look at the existing branches:

git checkout master
git branch

This feature is very useful for branches whose purpose is  documentation or project preview.

    
13.09.2015 / 02:29