Search code examples
gitcapistrano

Deploy fails on branch - Not a valid object name


I'm trying to deploy another branch with Capistrano. Deploying the master branch works fine, yet my "daniel" branch fails with the following error:

INFO[e8d2a50d] Running /usr/bin/env git archive daniel | tar -x -C /data/apps/dimsum.staging/releases/20150922073756 on <ip number>
DEBUG[e8d2a50d] Command: cd /data/apps/dimsum.staging/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/dimsum.staging/git-ssh.sh /usr/bin/env git archive daniel | tar -x -C /data/apps/dimsum.staging/releases/20150922073756 )
DEBUG[e8d2a50d]     fatal: Not a valid object name
DEBUG[e8d2a50d]     tar: This does not look like a tar archive
DEBUG[e8d2a50d]     tar: Exiting with failure status due to previous errors
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host <ip number>: git exit status: 2
git stdout: Nothing written
git stderr: fatal: Not a valid object name
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

These are my deploy files:

#deploy.rb
set :application, 'dimsum_v2'
set :repo_url, '[email protected]:<git repo>.git'

#staging.rb
set :stage, :staging
set :application, "dimsum.staging"

set :app_path, "/data/apps/#{fetch(:application)}"
set :branch, 'daniel'
set :deploy_to, fetch(:app_path)
server '<ip number>', user: 'deploy', roles: %w{web app}, my_property: :my_value

Cloning master and the daniel branch directly on the server works fine as well. E.g:

git clone -b daniel  [email protected]:<git repo>.git

What can be the problem?


Solution

  • If you're sure [email protected]:<git repo>.git has the daniel branch, then maybe it wasn't there at the time when Capistrano created the /data/apps/dimsum.staging/repo folder.

    Just rm that repo/ dir in the server so cap creates it again from scratch (: