Git: how to deploy to gh-pages branch?
## Method 1
```sh
git checkout gh-pages
git checkout --
git add .
git commit -m "update"
git push
git checkout master
```
## Method 2
- https://gist.github.com/tduarte/eac064b4778711b116bb827f8c9bef7b
```sh
git checkout master # you can avoid this line if you are in master...
git subtree split --prefix dist -b gh-pages # create a local gh-pages branch containing the splitted output folder
git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
git branch -D gh-pages # delete the local gh-pages because you will need it: ref
```
## Method 3
```sh
git push origin `git subtree split --prefix dist master`:gh-pages --force
```
## Method 4
- https://gist.github.com/cobyism/4730490
```sh
git subtree push --prefix gh-pages
```
```sh
#!/bin/sh
if [ -z "$1" ]
then
echo "Which folder do you want to deploy to GitHub Pages?"
exit 1
fi
git subtree push --prefix $1 origin gh-pages
```
git gh-deploy path/to/your/site
![yubao_blog_cover](https://raw.githubusercontent.com/yubaoliu/assets/image/yubao_blog_cover.png)
No comments