昨天晚上将2015年一篇不负责的Git服务器搭建的教程更新了一下.详见 在CentOS下搭建自己的Git服务器及使用nginx配置gitweb面板
今天折腾了一些本地的项目,倒是可以了.
现在的需要是 将远程的仓库,同步一份到自己的git服务器.
开始想的是,远程clone下来本地,然后本地提交一次到自己的git服务器 . 实在是太二了...
我的需求是
Git服务器A: github之类的远程仓库
Git服务器B: 我自己搭的内网的.
我要在B上面建个仓库,自动同步服务器A的
so... 按上面的想法,还要手工,还不能自动,还不能定时...太SB了
一般搜寻之后有了,我本地的仓库地址是/www/git
目录下.所以以下的就不多解析了.
现在我假设要同步https://github.com/easysoft/zsite
这个项目,并让它半夜自动更新
mkdir /www/git/chanzhi.git
cd /www/git/chanzhi.git
git clone --mirror https://github.com/easysoft/zsite.git ./
就OK了..
至于定时更新
git --git-dir=/www/git/chanzhi.git remote update
来个脚本,方便一些
#!/bin/bash
read -p "请输入本地仓库名称:" name
read -p "请输入远程仓库地址:" url
if [ ! -n "$name" ];then
echo "不能为空"
else
mkdir -p /www/git/crond_$name.git
cd /www/git/crond_$name.git
git clone --mirror $url ./
echo "1 1 * * * git --git-dir=/www/git/crond_$name.git remote update" >> /var/spool/cron/root
echo "http://git.lvtao.net/crond_$name.git"
fi
版权属于: 吕滔博客
原文地址: https://www.lvtao.net/config/git-other-auto-time-rync.html
转载时必须以链接形式注明原始出处及本声明。