Monday, 13 February 2017

Start a Empty Branch in Git

We are trying to create an EMPTY branch called gh-pages:
$cd repo

$ git checkout --orphan gh-pages
# create an orphan branch and it is independent
Switched to a new branch 'gh-pages'

git rm -rf .
# delete all the files under the original source tree
rm '.gitignore'
Note that you won't see the current new branch if you do git branch until the first commit happens. So let's now add something.
$ echo \"My GitHub Page\" > index.html
$ git add .
$ git commit -a -m \"First pages commit\"
$ git push origin gh-pages
After commit, we can now see the new branch with git branch and we can push it to the remote repo.

ref:
http://skyao.github.io/2015/03/18/git-create-empty-branch/

No comments:

Post a Comment