使用Git推送部署项目 [英] Deploy a project using Git push

查看:126
本文介绍了使用Git推送部署项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用 git push 部署网站吗?我有一个预感,它与使用 git hooks有关在服务器端执行 git reset --hard ,但是我该如何完成这个?

Is it possible to deploy a website using git push? I have a hunch it has something to do with using git hooks to perform a git reset --hard on the server side, but how would I go about accomplishing this?

推荐答案

我发现这个脚本关于本网站,它似乎工作得很好。

I found this script on this site and it seems to work quite well.


  1. 将您的.git目录复制到您的Web服务器

  2. 在本地副本上,修改您的。 git / config文件,并将您的Web服务器添加为远程:

  1. Copy over your .git directory to your web server
  2. On your local copy, modify your .git/config file and add your web server as a remote:

[remote "production"]
    url = username@webserver:/path/to/htdocs/.git


  • 在服务器上,替换。 git / hooks / post-update with 此文件(在下面的答案中)

    将执行访问权限添加到文件(再次,在服务器上):

    Add execute access to the file (again, on the server):

    chmod +x .git/hooks/post-update
    


  • 现在,只需在本地推送到您的Web服务器,它应该自动更新工作副本:

  • Now, just locally push to your web server and it should automatically update the working copy:

    git push production
    


  • 这篇关于使用Git推送部署项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆