自动同步github项目到本地gitlab
许多公司选择gitlab用作内部代码管理软件。有时候可能需要将一些开源项目同步到内部gitlab,但是只有企业版的才支持该功能。 但是通过git+定时任务也可以简单地实现该需求:1.将github项目clone到本地git clone https://github.com/xxxx/xxxx.git2.添加用于同步github项目的内部gitlab远程仓库git remote add g...
·
许多公司选择gitlab用作内部代码管理软件。有时候可能需要将一些开源项目同步到内部gitlab,但是只有企业版的才支持该功能。 通过git+定时任务可以简单地实现该需求:
1.将github项目clone到本地
git clone https://github.com/xxxx/xxxx.git
2.添加用于同步github项目的内部gitlab远程仓库
git remote add gitlab http://gitlab.your_company.com/xxxx/auto-pull-github.git
# 查看远程remote
git remote -v
gitlab http://gitlab.your_company.com/xxxx/auto-pull-github.git (fetch)
gitlab http://gitlab.your_company.com/xxxx/auto-pull-github.git (push)
origin https://github.com/xxxx/xxxx.git (fetch)
origin https://github.com/xxxx/xxxx.git (push)
- 自动同步脚本
# git-auto-sync.sh
project_path=/path/to/project
cd $project_path
git pull origin master
git push gitlab master
- 设置定时任务
crontab -e
# 每小时同步执行一次同步脚本
0 */1 * * * /path/to/git-auto-sync.sh
# 查看定时任务执行情况
tail -f /var/log/cron
更多推荐
所有评论(0)