Pergunta

On the server, /home/git/xxx/hooks/post-receive:

#!/bin/bash

cd /var/www/xxx
git pull

On the server, /var/www/xxx was created like this:

cd /var/www
git clone /home/git/repositories/xxx.git

When I run "git push" on the client, got this message:

remote: fatal: Not a git repository: '.'

Any ideas?

Foi útil?

Solução

Per your comment, you want to automatically update a website when changes are pushed to a Git repository. Try this: http://www.ekynoxe.com/automated-deployment-on-remote-server-with-git/

Note that the website root directory (/var/www/xxx) is not a Git repository itself; it just holds the working tree.

Outras dicas

As described here, the problem is that GIT_DIR is set to . when the hook is called.

If you unset GIT_DIR in the post-receive hook, it should work:

#!/bin/bash

unset GIT_DIR
cd /var/www/xxx
git pull

You are missing the pulled directory,

cd /var/www
git clone /home/git/repositories/xxx.git

Above command will create a new directory under /var/www as xxx, Provided your application name is xxx.

Now you need to go in this newly created directory like,

cd /var/www/xxx

Now run the command "git push". This should work.

Repositories folder should be bare repository.

git init --bare
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top