Ubuntu automatically pull from Github repo

老子叫甜甜 提交于 2019-12-13 12:07:39

问题


I installed git on my server but I want it to pull from my github repo whenever I push the changes I made locally.

I've looked into hooks but it's very confusing and I can't find any tutorials. Does anyone know how to do that?


回答1:


I want my server to pull from the repo after each commit

That looks like a webhook: your server would listen to a pull event (JSON payload) emitted by GitHub.

You will find many example of listener, like zenhacks/github-webhook-listener in CoffeeScript.




回答2:


Instead of having it automatically pull from Github, I just made a repository on my own server following this guide. How To Set Up Automatic Deployment with Git with a VPS

What this does is make it so that whenever i'm finished working on my site locally i'll push the repo on my server. Everytime the server gets a repo change it will checkout to my website directory.

I can also set up my local computer to push to Github at the same time, too. Very helpful guide I recommend it.




回答3:


But simple script might work then, call it gpush:

#!/bin/bash
git pull
if [$? -ne 0]; then
    ... error processing
fi
git push


来源:https://stackoverflow.com/questions/31175338/ubuntu-automatically-pull-from-github-repo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!