2

I'm attempting to create a Git repo with a separate worktree. I followed this tutorial to the letter: http://caiustheory.com/automatically-deploying-website-from-remote-git-repository

I am able to commit from my local repo and push to my remote. The file path that I've designated as the worktree does not contain the files that I've pushed.

I'm thinking that the file path might be incorrect (I'm on a MediaTemple GS), but Git doesn't throw any errors when I push.

Here's the config from my remote:

[core]
repositoryformatversion = 0
filemode = true
bare = false
worktree = /home/xxxxx/domains/xxxxxx.com/html/b

[receive]
denycurrentbranch = ignore

My post-receive and post-update hook are both 777 and both contain this:

#!/bin/sh
git checkout -f

I'd truly appreciate any help provided.

Thanks,

--Nick

suvayu
  • 4,271
  • 2
  • 29
  • 35

1 Answers1

1

You'll want something like this:

https://github.com/richo/git_template/blob/master/hooks/post-receive

Or more succinctly:

#!/bin/sh

# Kludge to read the last ref
while read old new ref; do
real_sha=$new
done

GIT_WORK_TREE=$PWD/../ git checkout -qf $real_sha

Basically, the new refs are passed into post-receive in stdin, so you need to read them in manually.

What your hook is doing is forcibly checking out the existing ref.

richo
  • 8,717
  • 3
  • 29
  • 47