mercredi 3 juin 2015

Remote website synchronized with git local branch

In an EC2 AWS instance, I have a remote bare git repository created following:

@server:~$ mkdir -p /home/myuser/domain.git && chmod 770 /home/myuser/domain.git && cd /home/myuser/domain.git && git init --bare

With a post-receive hook:

@server:~$ nano hooks/post-receive

The hook script is:

#!/bin/sh
sudo git --work-tree=/var/www/domain --git-dir=/home/myuser/domain.git checkout -f

It has permission to execute:

@server:~$ chmod +x hooks/post-receive

I work on a local repo following:

@local:~$ 
    git init
    git remote add server server:/home/myuser/domain.git
    git checkout -b www-dev
    git add .
    git commit -am "Initial"

However, when I push changes:

@local:~$ git push server www-dev

The hook fails:

remote: fatal: You are on a branch yet to be born
To server:/home/myuser/domain.git
   06709ae..d1d7ead  www-dev -> www-dev

And the website is not updated. Why?




Aucun commentaire:

Enregistrer un commentaire