title: How to fix "cannot lock ref" error while deploying on server using capistrano?
body: <p>I was trying to deploy a hotfix to my staging server (DigitalOcean) but got a "cannot lock ref" error. I stumbled on this error before. I had a branch 'hotfix' and then I created 'hotfix/some-hotfix' branch and when I tried to push it to origin I got the error. I fixed it by deleting branch 'hotfix' in my repository (BitBucket). But now I am getting it while deploying on staging server.</p>
  
  <p>Stack trace:</p>
  
  <pre><code>SSHKit::Command::Failed: git exit status: 1
  git stdout: Fetching origin
  error: cannot lock ref 'refs/heads/hotfix/my-hotfix-branch-name': 'refs/heads/hotfix' exists; cannot create 'refs/heads/hotfix/my-hotfix-branch-name'
  From bitbucket.org:username/repo-name
  ! [new branch] hotfix/my-hotfix-branch-name -&gt; hotfix/my-hotfix-branch-name (unable to update local ref)
  error: some local refs could not be updated; try running
  'git remote prune origin' to remove any old, conflicting branches
  error: Could not fetch origin
  git stderr: Nothing written
  </code></pre>
  
  <p>I tried running <code>git remote prune origin</code> but it didn't help.
  I'm stuck with no ideas here</p>