You have one single repo (master
) in which you have both project code (project
) and the project website (website
) which you want to push to gh-page
. The directory structure looks like this.
-- project
|-- website
| |-- _layouts
| |-- _includes
| |-- _posts
| |-- _site
| |-- assets
| |-- index.md
|
|-- files01
|-- files02
|-- files03
|-- ...
You are on the master
tree and in the project
root folder. First build the site using Jekyll
cd website
jekyll build
cd ..
You want to commit these changes to the master
git add website/_site/*
git commit -m "Site Update"
Now you want to just deploy the built static site. So you want to push contents of the website/_site/
folder into root directory of gh-pages
.
git subtree split --prefix website/_site/ -b gh-pages
git push -f origin gh-pages:gh-pages
git branch -D gh-pages
Or if you want to do with single line, you can do.
git push -f origin `git subtree split --prefix website/_site/ master`:gh-pages