Fork me on GitHub

Git之镜像仓库全攻略

Git镜像仓库应用全攻略指南

概述

以下案例以GitHub上的仓库作为原仓库,在国内或者公司局域网部署镜像仓库。使用https://github.com/mds1455975151/ansible-role-pip.git仓库作为原仓库。

应用场景

  • 加速访问GitHub仓库
  • GitHub负载均衡(类似MySQL的读写分离架构)

原生git clone –mirror实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# cd /opt/
# git clone --mirror https://github.com/mds1455975151/ansible-role-pip.git
# ls -al
total 16
drwxr-xr-x. 4 root root 4096 Jul 7 13:31 .
dr-xr-xr-x. 20 root root 4096 Jul 7 13:33 ..
drwxr-xr-x 7 root root 4096 Jul 7 13:31 ansible-role-pip.git
drwxr-xr-x. 2 root root 4096 Mar 26 2015 rh
# git clone 10.135.95.147:/opt/ansible-role-pip.git .
Cloning into '.'...
remote: Counting objects: 181, done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 181 (delta 75), reused 181 (delta 75)
Receiving objects: 100% (181/181), 18.78 KiB | 0 bytes/s, done.
Resolving deltas: 100% (75/75), done.
[root@VM_95_147_centos tmp]# ll
total 36
drwxr-xr-x 2 root root 4096 Jul 7 13:35 defaults
drwxr-xr-x 2 root root 4096 Jul 7 13:35 handlers
drwxr-xr-x 2 root root 4096 Jul 7 13:35 meta
-rw-r--r-- 1 root root 1233 Jul 7 13:35 README.md
-rw-r--r-- 1 root root 28 Jul 7 13:35 requirements.yml
drwxr-xr-x 2 root root 4096 Jul 7 13:35 tasks
drwxr-xr-x 2 root root 4096 Jul 7 13:35 templates
drwxr-xr-x 2 root root 4096 Jul 7 13:35 tests
drwxr-xr-x 2 root root 4096 Jul 7 13:35 vars

利用gogs实现

查看迁移和镜像仓库设置
1、添加迁移外部仓库

2、配置克隆地址、授权信息、迁移类型等信息

3、设置仓库同步频率

4、配置并立即同步

利用github-mirrors实现

https://docs.gitlab.com/ee/workflow/repository_mirroring.html

参考资料

======================================================
希望各位朋友支持一下

本文作者:dongsheng
本文地址https://mds1455975151.github.io/archives/177a4e8b.html
版权声明:转载请注明出处!

坚持技术分享,您的支持将鼓励我继续创作!