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

Asked

Viewed 1,677 times

2

I need to create a clean branch that doesn’t reflect the master branch commits. This branch will be used to provide information about the project on Github through Gh-pages and will never be used to merge with the master branch.

1 answer

6


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 to the server:

git push origin gh-pages

Make a checkout for the master and see the existing branchs:

git checkout master
git branch

This feature is very useful for branches that have as purpose project documentation or preview.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.