Created
October 29, 2018 20:12
-
-
Save renatoathaydes/75fcf8c5104134ae112f367d5e4f3f50 to your computer and use it in GitHub Desktop.
Use git worktree to maintain GitHub Pages branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initialize a gh-pages branch... GitHub expects this branch to exist to publish a project website from it. | |
git checkout --orphan gh-pages | |
git reset --hard | |
git commit --allow-empty -m "Initializing gh-pages branch" | |
git push origin gh-pages | |
git checkout master | |
# Define a directory where the static website files will reside | |
WEBSITE_DIR=target | |
# Add a working tree for the new gh-pages branch (this allows us to work on the website without checking out that branch) | |
rm -rf $WEBSITE_DIR | |
git worktree add -B gh-pages $WEBSITE_DIR origin/gh-pages | |
# TODO build the website into the WEBSITE_DIR directory | |
<replace-this-with-the-commmands-to-build-the-website-into-WEBSITE_DIR> | |
# Publish the just-built website files | |
cd $WEBSITE_DIR && git add --all && git commit -m "Publishing to gh-pages" && cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment