我如何设置一个git钩子从Github中拉出? [英] How do I setup a git hook to pull from Github?
问题描述
我在Mac上进行开发,并将其推送到Github.我通过SSH登录到服务器,然后将更改添加到服务器.我希望将更改推送到Github时将更改自动拉到服务器,所以我将文件.git/hooks/post-update包含此信息
I develop on my Mac and push it to Github. I login to my server by SSH and I git pull the changes to the server. I want the changes to automatically be pulled to the server when I push them to Github so I a file .git/hooks/post-update with this info
#!/bin/sh
echo
echo "**** Pulling changes into Live [Hub's post-update hook]"
echo
cd /mydirector/html || exit
unset GIT_DIR
git pull
exec git-update-server-info
我还应该怎么做才能使其正常工作?预先感谢您的回答.将不胜感激.
What else should I do to get it working? Thanks in advance for your answer. It will be very much appreciated.
推荐答案
您还可以在GitHub上声明 webhook ,以生成事件有效载荷,该进程可以通过您的服务器.
You could also declare a webhook on GitHub, in order to generate an event payload that can be listened to by a process on your server.
该进程(一个侦听器)将负责触发git pull
.
That process (a listener) would be in charge of triggering the git pull
.
您将找到此类侦听器的各种示例,例如:
You will find various examples of such listeners, like:
- a basic php one
- one in go
- or in python
这篇关于我如何设置一个git钩子从Github中拉出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!