Based on this answer I tried to implement the following:
When pushing to the web repo, I do not want the whole repository contents to be copied to my web directory, but only certain files/directories.
So, in my post-receive
hook I do this:
GIT_WORK_TREE=/full/path/to/web/directory git checkout -f -- web/index.php
However, very strangely the version of index.php
in the directory never updates correctly. While a git log
inside my bare repository directory showed the latest commits that were pushed to it the version of index.php
is a previous one.
Also, I created a file called test
and added that to the paths above to be copied into the work tree - this also did not show up.
The file is definitely executed. I added an echo
command that shows up on my console, and I do some cleanup in the directory that is working as expected. All the files are there and updated. (I checked with a brand new git clone
.) There is only one branch, master
.
All this is very frustrating because it worked well when I first set it up. Don't know what could be wrong here. Thanks.
UPDATE:
I tried the following:
# added "testfile" at the end of the checkout line in post-receive
echo "Test" > testfile
git add testfile
git commit -m "Test."
git push web
>...
> remote: error: pathspec 'testfile' did not match any file(s) known to git.
>...
cd ..
git clone <remote web> newdir
>...
cd newdir
cat testfile
> Test
So the repo gets updated as expected but the new file is not recognized found. Maybe something wrong with the path specification?