Skip to content

Instantly share code, notes, and snippets.

@braveulysses
Created May 31, 2009 04:06
Show Gist options
  • Save braveulysses/120750 to your computer and use it in GitHub Desktop.
Save braveulysses/120750 to your computer and use it in GitHub Desktop.
A helper script for working with GitHub Git repositories.
#!/bin/bash
# A helper script for working with GitHub Git repositories.
function git_dir_check() {
if [ ! -d ".git" ]; then
echo "Not a git repository!"
exit
fi
}
function remove_jekyll_site_dir() {
# Presumably, you have "_site" in .gitignore, so it sticks around
# when you change branches.
if [ -d "_site" ]; then
rm -rf ./_site/
fi
}
function usage() {
echo "Usage: github [OPTION]"
echo
echo " help print this help."
echo " code check out MASTER branch."
echo " pages check out gh-pages branch."
echo
}
function terse_usage() {
echo "Usage: github [OPTION]"
echo
echo "Try 'github help' for more options."
}
if [ $# -gt 0 ]; then
if [ $1 == "code" ]; then
git_dir_check
remove_jekyll_site_dir
git checkout master
elif [ $1 == "pages" ]; then
git_dir_check
git checkout gh-pages
elif [ $1 == "help" ]; then
usage
else
echo "github: unknown option '$1'"
terse_usage
fi
else
terse_usage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment