Created
October 22, 2012 21:12
-
-
Save unixmonkey/3934374 to your computer and use it in GitHub Desktop.
Feature, Hack, and Ship
This file contains hidden or 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
| # =========================================================== | |
| # = feature && hack && rake test && ship = | |
| # = http://reinh.com/blog/2008/08/27/hack-and-and-ship.html = | |
| # =========================================================== | |
| # create new named feature branch and switch to it | |
| feature() { | |
| git checkout -b $1 | |
| } | |
| # show commits only this feature branch | |
| feature_commits() { | |
| CURRENT=`git branch | grep '\*' | awk '{print $2}'` | |
| echo "Commits in branch \"${CURRENT}\", but not \"master\":" | |
| git log master..${CURRENT} --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset" --abbrev-commit --date=relative | |
| } | |
| # show diff of things in this branch not in master | |
| feature_changes() { | |
| CURRENT=`git branch | grep '\*' | awk '{print $2}'` | |
| echo "Commits in branch \"${CURRENT}\", but not \"master\":" | |
| git diff master..${CURRENT} | |
| } | |
| # rebase the current state of master into the feature branch | |
| # and fast-forward your changes on top of that for easy | |
| # conflict resolution (or avoidance) | |
| hack() { | |
| CURRENT=`git branch | grep '\*' | awk '{print $2}'` | |
| git checkout master | |
| git pull origin master | |
| git checkout ${CURRENT} | |
| git rebase master | |
| } | |
| # switch to master and merge the feature changes, then | |
| # change back (in case you want to work more on that feature) | |
| # note: you should run your tests before shipping | |
| ship() { | |
| CURRENT=`git branch | grep '\*' | awk '{print $2}'` | |
| git checkout master | |
| git merge ${CURRENT} | |
| git push origin master | |
| git checkout ${CURRENT} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment