Skip to content

Instantly share code, notes, and snippets.

@schuyler
Created May 13, 2013 19:36
Show Gist options
  • Save schuyler/5570864 to your computer and use it in GitHub Desktop.
Save schuyler/5570864 to your computer and use it in GitHub Desktop.
simple Git workflow script
# Workflow:
#
# 1. feature start 000-new-feature
# 2. git commit -m "here's my new feature"
# 3. feature update
# 4. git commit -m "here's some tests"
# 5. feature diff
# 6. feature finish 000-new-feature
# 7. git push origin master
function feature {
usage="feature [start|finish|update|log|diff] <branch>"
if [ -z "$1" ]; then echo $usage; return 1; fi
case "$1" in
st*)
if [ -z "$2" ]; then echo $usage; return 1; fi
git checkout master
git pull --rebase origin master || return 1
git checkout -b $2
;;
fin*)
if [ -z "$2" ]; then echo $usage; return 1; fi
git checkout $2 || return 1
git pull --rebase origin master || return 1
git checkout master
git pull --rebase origin master || return 1
git merge --squash $2 || return 1
git commit || return 1
git branch -D $2
;;
up*)
git pull --rebase origin master
;;
log) ;&
diff)
if [ -n "$2" ]; then git checkout $2; fi
git $1 origin/master..HEAD
;;
*)
echo $usage
return 1
;;
esac
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment