Criando um repositório git de uma pasta de produção

Eu tenho uma máquina com um site de produção, eu quero criar um repositório git nessa máquina para gerenciar o site usando o git.

Então, a primeira coisa que fiz foi criar um repositório .git vazio na máquina de produção:

mkdir repos
cd repos
mkdir production.git
cd production.git
git init --bare

Neste repositório, abaixo de hooks / post-receive, adicionei as seguintes linhas:

#!/bin/sh
GIT_WORK_TREE=/var/www/production_website git checkout -f

Então baixei a pasta com meu site de produção para minha máquina local e iniciei o git:

cd production_website
git init

Depois disso fiz o primeiro commit:

git add .
git commit -m "first commit"

E finalmente adicionei o repositório remoto e fiz meu primeiro push:

git remote add origin ssh://[email protected]/repos/production.git
git push origin master

Mas quando eu faço o push me dá a seguinte mensagem de erro:

remote: fatal: This operation must be run in a work tree

Que é acionado quando o gancho pós-recebimento é ativado.

Alguma sugestão do que eu poderia estar fazendo errado?

ATUALIZAR:

Na primeira etapa, ao criar um repositório .git vazio na máquina de produção, se eu usargit init ao invés degit init --bare Eu recebo esta mensagem de erro quando faço um push:

remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

questionAnswers(1)

yourAnswerToTheQuestion