A Moderately Useful Bash Function

- - posted in programminglittle hacks

I find myself oftentimes telling my deployment system, Capistrano, which branch of my codebase to use when deploying to a staging server, when I need to test some code that I’m working on without merging it all in first. That happens to me so often, I wrote a command called deploy_current that grabs the current git branch you’re on, then tells Capistrano to check out that branch when deploying. Badda-boom badda-bing, space cadets.

  branch=$(git rev-parse --abbrev-ref HEAD)
  echo "!!! => Deploying branch \"$branch\""
  cap -S env="staging" branch="$branch" deploy

Put that into your ~/.bash_profile file and smoke it, y'all!

Update: For some reason, this bash function works only some of the time. I will update this post once I figure out why….