参考
https://blog.csdn.net/qq_41832237/article/details/103474283
开源github项目想要同步到本地gitlab
- 将github项目克隆至本地
项目需要是开源的,用户有权限clone
# git clone https://github.com/liuyueming/salt.git
- 添加用于同步github项目的内部gitlab远程仓库
# git remote add gitlab http://gitlab.your_company.com/xxxx/auto-pull-github.git
代码尾部是内部gitlab地址
查看远程remote
# git remote -v
- 自动同步脚本
# cat git_auto_sync.sh
# git-auto-sync.sh
project_path=/project_path
cd $project_path
echo "start" `date` >> /var/log/git_auto_sync.log
git pull origin main >> /var/log/git_auto_sync.log
git push gitlab main >> /var/log/git_auto_sync.log
echo "end" `date` >> /var/log/git_auto_sync.log
- 定时任务执行
# crontab -e
# 每小时执行一次
* */1 * * * bash git-auto-sync.sh
标签:git,log,auto,gitlab,sync,github,同步,本地
From: https://www.cnblogs.com/minseo/p/18264531