Trevor Oke

3737844653

Git Workflow

I still work more often in Subversion than I do in git, and the commands aren’t quite under my fingers yet. So, more for my memory than anything else, here’s my current git workflow for when I’m working on my own stuff.

First, I create a local version of the repository to work on.

1
git clone my-great-repository @

Next, I’m going to create a branch for whatever it is I’m working on at the moment. I tend to be a bit of a splitter when it comes to branches. One change, feature or fix, per branch. Git is great for that.

1
git checkout -b "stuff_Im_working_on"

After that, I do a small change at a time. Lots and lots of small commits. Loop over this as many times as you need.

1
git commit -a -m "Changed the text as requested."

When I’ve finished everything and it’s time to check my code back in, I checkout my master branch and make sure that I’ve got the latest commit.

1
git checkout master git pull

At that point, I’m ready to merge my new code into the master branch, run all of my tests, and push everything back up to the origin.

1
git merge "stuff_im_working_on" git push

When I’m done, I usually just trash the branch I’ve been working on.

1
git branch -d "stuff_im_working_on"

Please note, I generally work by myself and I’m not too worried about conflicting merges and the like. This workflow would obviously have to be modified to handle that.