Wednesday, September 9, 2009

git utilities workflow

One of my best workflow techniques it to use git cherry-pick to pull in what I call utility changes. A utility change would be like a change to point all the database configuration at the test database. Normally it's pointed at your local database. It takes a few minutes to make the change to the test database and sometimes you forget a spot. So to do it I first...

-- make the change to point at the test database --

# stash all your changes so you can checkout your utility branch
git stash

# checkout utility branch
git checkout utils

# put your changes back
git stash apply

# commit your changes to your utility branch
git commit -a -m "Point environment at the test database"

# switch back to the branch you were working on, trunk probably
git checkout trunk

# double check what branch you are on since you don't want to make a mistake
git branch

# find the commit sha number for those changes you just committed
git log utils

# cherry-pick just the change
git cherry-pick ab38b9

-- now you test your site against the test db --

-- you find out whatever you were looking for --

# get rid of the cherry picked commit from your branch and change back to pointing your database locally
git reset --hard HEAD^

your utility commit is still in your utils branch history so you can just git cherry-pick ab38b9 it out anytime you want and point at the test database.

No comments: