Skip to content

Instantly share code, notes, and snippets.

@pioz
Created July 19, 2017 17:14
Show Gist options
  • Select an option

  • Save pioz/969a1c5f600ec84ff528c2e706f79941 to your computer and use it in GitHub Desktop.

Select an option

Save pioz/969a1c5f600ec84ff528c2e706f79941 to your computer and use it in GitHub Desktop.
Push content of doc directory in master branch to gh-pages branch
#!/bin/bash
set -e
current_dir=$PWD
die() { cd $current_dir; echo $* >&2; exit 1; }
if [ $# != 1 ]; then
die "Usage: $0 REPO_PATH"
fi
if [ -d "$1/doc" ]; then
echo "Directory exists!"
cd $1
git checkout master || die "Can not checkout master branch!"
cp -r doc /tmp
git checkout gh-pages || die "Branch gh-pages does not exists!"
git pull origin gh-pages
rm -r *
cp -r /tmp/doc/* .
rm -r /tmp/doc
git add .
git commit -am "Update doc"
git push origin gh-pages || die "Can not push gh-pages branch!"
git checkout master
cd $current_dir
else
die "Doc dir '$1/doc' does not exists!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment