Thursday, February 2, 2012

Push-any Git post-update hook

Maintaining multiple branches in Git is very easy. Maintaing multiple "remotes" in Git is very easy. The tricky part comes when you join both.

Unless you have a testing, staging and production server and you maintain a branch per-server, aka remote, then you need to git your hands dirty with some code.

The other day, I wanted to have a single remote for testing multiple branches and the web had half the answer with this script, but unfortunately, it doesn't checkout the branch you're pushing.

After few lines of code, I can now push multiple branches to a non-bare remote repository and have the post-update automatically checkout the branch I pushed and update the worktree, handy huh?

Code is here. Your comments are welcome.

No comments:

Post a Comment