2

I've been trying to set up Git to manage my website, as explained per this tutorial and this one and this one and this one and this gist.

To summarize what I've done: (in-depth explanations can be found in the tutorials)

  1. Set up a bare git repo on my web server in /home/usr/mysite.git/
  2. In the bare repo, create an executable post-receive hook with GIT_WORK_TREE set to my web documents root, /home/www/mysite.com/
  3. In my local git repo, add the remote repository. This is from my .git/config :

    [remote "live"]
    url = ssh://user@ssh.myserver.com/home/usr/mysite.git
    fetch = +refs/heads/*:refs/remotes/live/*
    
  4. Push : git push live +master:refs/heads/master

Here's the output I get:

Everything up-to-date

Great!
Except it isn't : my remote web documents root /home/www/mysite.com/ is still empty.
I've tried everything I could but haven't been able to push the files into my remote folder.

Do you know what I've done wrong, or what I could do to debug this?

Robin Métral
  • 3,099
  • 3
  • 17
  • 32

3 Answers3

1

Try GIT_WORK_TREE instead of GIT_WORKING_TREE.

Lutz Büch
  • 343
  • 4
  • 12
  • Thank you Lutz! I just doubled checked and actually already had GIT_WORK_TREE. I must have mistyped my question! (I edited it) Any other idea what could be wrong? – Robin Métral Jul 21 '18 at 04:10
1

The repo might in fact be up-to-date. Verify that by running git show on your server. Instead, maybe your post-receive hook isn't actually executed. If so, maybe because it isn't set as executable?

Lutz Büch
  • 343
  • 4
  • 12
  • My hook is executable, `ls -l` says `-rwxrwxr-x` (same permissions and owner -me- as all other hooks). A weird thing I'm noticing is that all the other hooks are named `hook-name.sample`. The one I created is simple `post-receive`. Could this be relevant? – Robin Métral Jul 25 '18 at 08:48
  • As for `git show` in my bare repo, it returns my last commits. Color is green. Does this mean it's up-to-date? Then why is my GIT_WORK_TREE folder (my website root) still empty? – Robin Métral Jul 25 '18 at 08:50
  • Check if the hook script is actually executed. Test the script by running it manually. Or add a line in the hook script that will otherwise show (like `touch do-you-see-me`). If it doesn't, check if the executable bit is set for your hook script. – Lutz Büch Jul 25 '18 at 08:54
  • I was busy last week and just looked at my problem again today. I added the `touch` line as you suggested, and somehow the push now worked! I'm not really sure what solved it, nevertheless thank you very much for your help Lutz! – Robin Métral Jul 31 '18 at 00:24
0

Your .git/config should include a line starting with push in the section [remote "live"]. Otherwise it is only configured to fetch from that remote.

Lutz Büch
  • 343
  • 4
  • 12
  • Could you tell me specifically what I should be adding to my `.git/config`? Something like `push = +master:refs/heads/master` ? I can't seem to find any examples of this online. Thank you! – Robin Métral Jul 23 '18 at 09:53
  • I edited my .git/config. The git push still returns `Everything up-to-date` – Robin Métral Jul 24 '18 at 01:02