Monday, February 25, 2008
Git is amazing
So, today, I'm working on a project, I've got it all mocked out with some sample forms and some throwaway objects to play with.

I realize 'Hey, I need an authorization/authentication system', so I have a dilemma.

On the one hand, my code is throwaway that I plan to evolve to fit what I end up actually doing with it long term.

On the other hand, I really don't want to have to redo it later, since I'll probably want to come back here after I build out the auth/auth system.

Git to the rescue.

I've been doing all my development on the 'experimental' branch locally, as one ought to do.

git commit -m 'End of tinkering, time to get serious'

git checkout master #Back to the beginning,
#or you can use git checkout HEAD~x where x is how many commits you want to go back

#create the new branch and check it out
#equivalent of git branch restful_auth; git checkout restful_auth
git checkout -b restful_auth #which is a wonderful plugin, btw

# do your install here...

git commit -m 'All restful, now lets go back to the other'

git checkout experimental

git rebase restful_auth

# fix the conflicts, I had three

And you're done. You just saved yourself a couple hours of rewriting throw-away bits of your app. And of course, this is completely doable with pretty much any type of edit. You can go back into the past and effectively 'redo it right' without having to worry about the time it takes up front.

Labels: ,