This works with Capistrano >= 3.1:
add this line to config/deploy.rb
:
set :branch, ENV['BRANCH'] if ENV['BRANCH']
and then call capistrano with:
cap production deploy BRANCH=master
This solution works with Capistrano < 3.1:
# call with cap -s env="<env>" branch="<branchname>" deploy
set :branch, fetch(:branch, "master")
set :env, fetch(:env, "production")