push to deploy

1.server端

建立裸仓

$ mkdir ~/repo.git
$ cd ~/repo.git
$ git init --bare

脚本

$ vim ~/repo.git/hooks/post-receive
#!/bin/sh
git --work-tree=~/htdocs --git-dir=~/repo.git checkout -f
echo "Hooray, the new version is published!"
$ chmod +x ~/repo.git/hooks/post-receive

***复制仓库,如果是已有代码的,直接从server代码处git clone到本地来,跳过下步

$ git clone ~/repo.git ~/htdocs

2.client端

$ git remote add live ssh://your_username@your_hostname.tld/~/repo.git

已经好了,使用时直接push同步到server,如下:

$ git commit -m "your commit message"
$ git push live master

来源:https://ma.ttias.be/simple-git-push-workflow-deploy-code-server/

原文地址:https://www.cnblogs.com/fenle/p/5387653.html