Git Remote Hook Not Commiting
I'm trying to connect a remote on Rails to automatically push changes to this EC2. My remote looks like this.
pd ssh and then location ending in /eko_web.git (fetch)
pd same (fetch)
Pd points towards a bare git repo. It has a post-receive hook:
#!/bin/sh
GIT_WORK_TREE=/home/repo/eko_web git checkout -f
When I locally
git push pd production
and then go to my working tree I see all the files there but they haven't been added or committed. If while in that tree I add and commit all those files and then restart the server on my EC2 then I can see the changes on my website. But there must be a way to have add and commit occur automatically without need a server restart, preferably reflecting the commit history on the branch I pushed from locally.
You need to locally commit the files before pushing them otherwise you won't see them in your remote repository. From your top level working directory.
git commit -a .
Or if it's new files you need to add them first.
git add <file or directory>
git commit
Then you push:
git push pd production
Generally, you either need to restart or reload the server for your changed to take effect. If you want to do gracefully, meaning you don't connections to get dropped it's better to do a reload (This is usually sends a HUP signal to the process and tells it that there has been a configuration change) You could add this to your post-receive hook, something like:
sudo service apache2 reload
or
sudo service nginx reload
链接地址: http://www.djcxy.com/p/18920.html
上一篇: Git重置和Bootstrap
下一篇: Git远程钩子没有承诺