How do you do an automatic git pull on remote server?

后端 未结 2 1682
我寻月下人不归
我寻月下人不归 2020-12-16 01:40

Before I begin, I know there are a lot of questions similar to this one, but I am really having difficulty finding a concise, secure, best practice since the feedback on the

相关标签:
2条回答
  • 2020-12-16 02:04

    I had the same exact issue, strong in code and development skills, weak in sysadmin skills. When I was finally ready to push code I had to ask a GitHub rep what their suggested method was, and they responded with Capistrano. It's a Ruby application that runs commands (such as git pull) on remote servers, along with pretty much any other command you can imagine.

    Here a few articles you can read to get more info:

    • GitHub - Deploy with Capistrano

    • How to compile the Capistrano stack on your *nix system

    • Another example of how to deploy code with Capistrano

    Not going to lie, the learning curve was pretty steep, but once you start working with Capistrano, you will see that it works well for pushing code. I develop my applications in Symfony and I have my Capistrano set-up to pull code, clear cache and clear log files, all in one command from my local machine.

    0 讨论(0)
  • 2020-12-16 02:19

    You can do this quite easily with GitHub service hooks.

    You ll need to create one more file that will handle the process of performing the git pull. Add a new file, called github.php (or anything you wish ), and add:

    <?php `git pull`;
    

    Save that file, and upload it to the repository directory on your server. Then, go to Services Hooks -> Post-Receive URL and copy the URL to that file, and paste it into the “Post-Receive URL” E.g. http://demo.test.com/myfolder/github.php

    So, when you push, GitHub will automatically visit this URL, thus causing your server to perform a git pull.

    To see this in more details to go to this tutorial

    0 讨论(0)
提交回复
热议问题