Skip to content

Instantly share code, notes, and snippets.

@calebhaye
Last active December 11, 2015 01:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calebhaye/4522564 to your computer and use it in GitHub Desktop.
Save calebhaye/4522564 to your computer and use it in GitHub Desktop.
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment