Deploy once a specific branch with capistrano?

We have a very simple branching strategy:

  • develop -> Development branch
  • staging -> Staging Server Deploy Branch
  • master -> Productio Branch

Our production deploy workflow is develop -> staging -> master. We always deploy first to staging, we test for some time, and then we deploy to production.

  • Detailed explanation of 'git remote show'
  • create a new svn branch with git-svn
  • Git: how to maintain permanent parallel branches
  • git: how to move committed changes from master to branch?
  • Git rebase from one branch to another
  • How to move last commits to separate branches in Git
  • Right now we’re working in a new feature that I would like to test. I don’t want to put it in staging because, since is experimental, I would not like to lock a production deploy until the feature is finished.

    Is there a way to say to capistrano the branch I want for one particular deploy, so I could put this experimental code in staging to test it?

    OBS: The reason I need to put in staging is that this piece of code depends on a lot of external resources that are already configured in staging and would be difficult to replicate locally.

  • Can I recover a branch after its deletion in Git?
  • How can I start a clean branch with no ancestry, then commit files progressively?
  • How to create a new empty branch for a new project
  • Can I pull to a branch other than the one I'm on?
  • How to separate productive/dev environment on a server with git?
  • Do you feel comfortable merging code?
  • One Solution collect form web for “Deploy once a specific branch with capistrano?”

    Here’s how I do it.

    At the top of my config/deploy/staging.rb file, I put this:

    set :branch, ENV.fetch("CAPISTRANO_BRANCH", "staging")

    This tells Capistrano that when I run cap staging deploy, use the staging branch by default, but allow that to be overridden by the CAPISTRANO_BRANCH environment variable.

    So now if I want to deploy a custom branch to staging, it is as simple as this:

    CAPISTRANO_BRANCH=my-feature cap staging deploy
    Git Baby is a git and github fan, let's start git clone.