revisions snippets

"updating paths is incompatible with switching branches/forcing" error when using git branches with Vlad

Tagged vlad, git, branch, deploy, revisions, tags  Languages 

I ended up writing this snippet after I found out that deploying a git branch with vlad wasn't as easy as it should've been...

I assumed the Vlad documentation was right, so I put the branch name in the revision variable (located in config/deploy.rb):

set :revision,              'branch_name'

But then I got this error when executing rake vlad:deploy:

git checkout: updating paths is incompatible with switching branches/forcing
Did you intend to checkout 'branch_name' which can not be resolved as commit?

I managed to solve the problem by using the SHA1 hash of the branch instead of the branch name, but that only worked for the current revision:

set :revision,              'd34360870be6536992e6d45bb0aa72eca31e14443'

So after some googling I found this post at scie.nti.st, which made my day because it has the following examples of how to deploy tags and branches with git and Vlad:

# Deploy the latest code, this the default
set :revision, "HEAD" 

# Deploy branch "origin/branch_name"
set :revision, "origin/branch_name"
 
# Deploy tag "1.0"
set :revision, "1.0"

Note that you have to push the branch to the remote server before running rake vlad:deploy:

git push origin branch_name