简体   繁体   中英

Pull files into web dir from git repo

I've seen many pages and posts about this and not one of them works on my Digital Ocean droplet.

I have a live rails app deployed with Capistrano, which means I had to push it to the server with Git before deploying. So Git works. Yet, now I want to update the site with some changes and while the remote repo is up to date (verified with git log ), the web directory is not up to date.

I know I need to get the new files across to that dir, but how?

hooks/post-receive:

#!/bin/sh
git checkout -f

Nada. I also ran sudo ./post-receive , just to be sure the post-receive hook executed (yes, it is executable). No output. Just another CLI prompt.

Why is it so ridiculously difficult to get a folder to contain the latest git push??

You are missing an unset GIT_DIR line, assuming your hook is in a bare repository (one without checked out files) in myrepo.git/hooks

#!/bin/sh
unset GIT_DIR
cd /path/to/checkout/repository
git pull
git checkout -f

The unset will make sure Git will consider your checked out repository as the current one (instead of the bare repo)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM