Capistrano failing with fatal: Not a git repository

I’m having a problem deploying my Rails app on my staging environment.

The error message I get is “fatal: Not a git repository” which doesn’t really make sense to me.

This is the output Capistrano returns when I run it:

I searched for a solution and I tried pretty much everything, I even tried to completely remove the application directory and deploy again from scratch.
I tried to repeat the commands that fail directly on the server, and again I have “fatal: Not a git repository”, for example:

cd /home/deployer/apps/XXXX/current && ~/.rvm/bin/rvm 2.1.1 do bundle exec sidekiqctl quiet /home/deployer/apps/XXXX/shared/tmp/pids/
fatal: Not a git repository (or any of the parent directories): .git

I’ve tried to switch branch to a production branch that deployed just fine a couple of hours before with no changes: same problem.

I absolutely have no idea how to debug this.
Any suggestion is highly appreciated.

UPDATE: It doesn’t seem there’s a problem interacting with the repo on github, but with the local environment. I think what it’s complaining about is that the project directory isn’t a git repository, which doesn’t even make sense to me…

Git Baby is a git and github fan, let's start git clone.