长虫山小木屋

没有谁会为你踏雪而来 喜欢的风景要躬亲筚路

  博客园  :: 首页  :: 新随笔  :: 联系 ::  :: 管理

1、在本地要部署的目录

git init
git clone --bare ./ my_project.git

把本地init仓库克隆到 my_project.git

2、上传my_project.git所有内容到服务器某处,比如 /home/test/

3、在服务器,/home/test/my_project.git/hooks/ 新建 post-receive

#!/bin/bash

git --work-tree=/home/project checkout -f

此目录/home/project是服务器网址部署目录

4、添加post-receive的执行权限:

chmod +x post-receive

5、本地执行

git remote add test root@test.com:/home/test/my_project.git //连接远程仓库并建了一个名叫XXXXX的别名
git add . git commit -m "me" git push -u test master

结束。

前提是ssh root@test.com已经创建了私钥连接,不用输入密码登录。

方法:

ssh-keygen -t rsa -C xxxxx@qq.com

把产生的 id_rsa.pub 内容添加到服务器/root/.ssh/authorized_keys

posted on 2021-02-03 15:04  长虫山小木屋  阅读(109)  评论(0编辑  收藏  举报