用git部署网站代码到生产环境VPS - 开发说
当前位置: 主页 » Centos » 用git部署网站代码到生产环境VPS

用git部署网站代码到生产环境VPS

      2017年08月04日   阅读 1,456 次     0 评论   Tags: ·

服务器端git配置:

[root@ImmenseGargantuan-VM home]# yum install git -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repos-lax.psychz.net
 * epel: mirror.hmc.edu
 * extras: mirror.hostduplex.com
 * updates: mirrors.ocf.berkeley.edu
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-6.el7_2.1 will be installed
--> Processing Dependency: perl-Git = 1.8.3.1-6.el7_2.1 for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Running transaction check
---> Package perl-Git.noarch 0:1.8.3.1-6.el7_2.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                             Arch                              Version                                         Repository                       Size
=============================================================================================================================================================
Installing:
 git                                 x86_64                            1.8.3.1-6.el7_2.1                               base                            4.4 M
Installing for dependencies:
 perl-Git                            noarch                            1.8.3.1-6.el7_2.1                               base                             53 k

Transaction Summary
=============================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 4.4 M
Installed size: 22 M
Downloading packages:
(1/2): perl-Git-1.8.3.1-6.el7_2.1.noarch.rpm                                                                                          |  53 kB  00:00:00     
(2/2): git-1.8.3.1-6.el7_2.1.x86_64.rpm                                                                                               | 4.4 MB  00:00:01     
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                        3.7 MB/s | 4.4 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : git-1.8.3.1-6.el7_2.1.x86_64                                                                                                              1/2 
  Installing : perl-Git-1.8.3.1-6.el7_2.1.noarch                                                                                                         2/2 
  Verifying  : perl-Git-1.8.3.1-6.el7_2.1.noarch                                                                                                         1/2 
  Verifying  : git-1.8.3.1-6.el7_2.1.x86_64                                                                                                              2/2 

Installed:
  git.x86_64 0:1.8.3.1-6.el7_2.1                                                                                                                             

Dependency Installed:
  perl-Git.noarch 0:1.8.3.1-6.el7_2.1                                                                                                                        

Complete!
[root@ImmenseGargantuan-VM home]# mkdir git
[root@ImmenseGargantuan-VM home]# cd git/
[root@ImmenseGargantuan-VM git]# mkdir qead.git
[root@ImmenseGargantuan-VM git]# cd qead.git/
[root@ImmenseGargantuan-VM qead.git]# git init --bare
Initialized empty Git repository in /home/git/qead.git/
[root@ImmenseGargantuan-VM qead.git]# cp hooks/post-update.sample  hooks/post-update
[root@ImmenseGargantuan-VM qead.git]# vi hooks/post-update
[root@ImmenseGargantuan-VM qead.git]# cat hooks/post-update
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
//添加此行:work-tree你的网站目录,git-dir你的git版本控制器目录,意义利用git hooks(钩子)实现实时更新网站文件,~~也有人说使用post-receive钩子(无效)~~
git --work-tree=/home/qead --git-dir=/home/git/qead.git/ checkout -f
exec git update-server-info

本地端设置:netbeans为例

1、新建项目并初始化git仓库
QQ截图20170805054037.jpg
QQ截图20170805054055.jpg
QQ截图20170805054142.jpg

2、首次提交到本地仓库,因为在服务器端建立的是空的仓库
QQ截图20170805054241.jpgQQ截图20170805054300.jpg

3、远程推入到服务器端git仓库,配置远程git仓库的信息
QQ截图20170805054425.jpg
QQ截图20170805054452.jpgQQ截图20170805054528.jpgQQ截图20170805054539.jpgQQ截图20170805054605.jpg

4、在netbeans新建test文件,先提交本地,在远程推入
QQ截图20170805054740.jpgQQ截图20170805055643.jpgQQ截图20170805055717.jpg

  • 版权声明:本文版权归开发说和原作者所有,未经许可不得转载。文章部分来源于网络仅代表作者看法,如有不同观点,欢迎进行交流。除非注明,文章均由 开发说 整理发布,欢迎转载,转载请带版权。

  • 来源:开发说 ( https://www.kaifashuo.com/ ),提供主机优惠信息深度测评和服务器运维编程技术。
  • 链接:https://www.kaifashuo.com/98.html
  • 评论(0

    1. 还没有任何评论,你来说两句吧

    发表回复

    您的电子邮箱地址不会被公开。 必填项已用 * 标注