# see - http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html # get latest from master git pull origin master # set "current feature" variable and create feature branch export CURRENT_FEATURE=1234567-feature-name git checkout -b $CURRENT_FEATURE # or use the following to get the current branch name CURRENT_FEATURE=$(git symbolic-ref -q HEAD) CURRENT_FEATURE=${CURRENT_FEATURE##refs/heads/} CURRENT_FEATURE=${CURRENT_FEATURE:-HEAD} echo "CURRENT FEATURE: $CURRENT_FEATURE" # Do work. Commit early and often. # Rebase against the upstream frequently to prevent your branch from diverging significantly: git checkout master git pull git checkout $CURRENT_FEATURE git rebase master # Once work on the feature is complete, you will have a branch with a lot of small commits like # - “adding a model and a migration” # - “adding a controller and some views” # - “oh crap - adding tests”... and so on. # if you need to push your local branch to remote, use: # git push -u origin $CURRENT_FEATURE # ... but try to avoid doing so unless necessary # We want the rebase to affect only the commits we’ve made to this branch, # not the commits that exist on the upstream. # To ensure that we only deal with the “local” commits, use: git rebase -i origin/master # merge your changes back into master git checkout master git merge $CURRENT_FEATURE # push your changes git push origin master