美文网首页HexoGit
Google 云服务搭建 git服务,实现Hexo自动部署

Google 云服务搭建 git服务,实现Hexo自动部署

作者: GloryMan | 来源:发表于2018-01-09 15:13 被阅读41次

title: Google 云服务搭建 git服务,实现Hexo自动部署
date: 2017-04-21 16:27:51
categories:

  • Document
  • Hexo
    tags:
    • Ubuntu
    • Nginx
    • Hexo

Google 云服务搭建 git服务,实现Hexo自动部署
前提:
google服务器
Hexo安装

安装 Git

sudo apt-get update
sudo apt-get install git

创建一个git

初始化一个名为blog.git的目录
git init --bare blog.git
Git指令

配置 Git

打开 Git 目录
cd cd blog.git/hooks/

output

  • applypatch-msg.sample
  • commit-msg.sample
  • post-receive (默认是没有这个文件的,这是我配置过的)
  • post-update.sample
  • pre-applypatch.sample
  • pre-commit.sample
  • prepare-commit-m
  • pre-push.sample
  • pre-rebase.sample
  • update.sample

使用 nano post-receive 创建一个文件打开

加入

#!/bin/bash -l
GIT_REPO=/home/用户就/blog.git
#需要创建这个目录
TMP_GIT_CLONE=/home/用户/tmp/blog
#这个是你期望打开文件的位置
PUBLIC_WWW=/var/www/public
rm -rf ${TMP_GIT_CLONE}
git clone $GIT_REPO $TMP_GIT_CLONE
rm -rf ${PUBLIC_WWW}/*
cp -rf ${TMP_GIT_CLONE}/* ${PUBLIC_WWW}

保存 control + X 、 Y 、 回车

更改本地 Hexo 配置文件_config.yml

deploy:
    type: git
    repo: 你服务器的用户字@serveip:blog.git,master

参考

Hexo自动部署

相关文章

网友评论

    本文标题:Google 云服务搭建 git服务,实现Hexo自动部署

    本文链接:https://www.haomeiwen.com/subject/xrtgnxtx.html