Recently I’ve been trying to get my head around git, I think my head has been tainted by excess subversion usage. Thanks to the help of close friend Joel Stanley I’ve got to the stage where I’m fairly happy with how I can use git to accommodate my workflow with multiple developers.

The following workflow is what I use at work when working on projects with frequent pushes by multiple developers. Perform all work on local branches, and then when ready to push we push (I now tend to have a branch for random working called ‘working’ and specific feature branches called whatever).

# switch to working branch
git checkout working

# hack hack hack then git add, etc
git commit -m"awesome change"
# hack hack hack then git add, etc
git commit -m"another awesome change"

# when I want to push these changes to the upstream master:
# first pull the latest master from upstream
git checkout master
git pull

# rebase those changes into my branch (put my commits on-top of the master's commits)
git checkout working
git rebase master

# after any conflicts are resolved, merge my working branch into master
git checkout master
git merge working

# push the changes upstream
git push

This workflow is similar for feature branches as well (working is essentually my feature branch for misc work, quick fixes, whatever). With this workflow I can easily change back to the master branch and pull the latest upstream changes in without impacting anything I’m currently working on (which is handy), as well as rebase as often as I want to (less conflcits to resolve, the better!).

Please let me know of any improvements or things I should watch out for, thanks!