Mirror repository từ GitLab sang GitHub

Code được cập nhật trên GitLab, GitHub tự động nhận bản mới nhất. Chính repository này là bản demo: source nằm trên GitLab và được push mirror sang GitHub.

Khi tạo repository mới trên GitHub, GitHub cho phép import repository từ nguồn git khác.

Màn hình import repository của GitHub

Tuy nhiên import chỉ chạy một lần. Nếu vẫn muốn làm việc trên GitLab mà GitHub luôn có code mới nhất, hãy dùng push mirror của GitLab theo các bước dưới đây.

1. Tạo GitHub Personal Access Token

Tạo fine-grained token trên GitHub Chọn quyền Contents read and write

1.1. Nếu repository thuộc Organization

Cài đặt fine-grained token cho organization

2. Thiết lập mirror trên GitLab

Form Mirroring repositories trên GitLab

3. Kiểm tra trạng thái

Sau khi thiết lập, mirror được liệt kê với URL dạng:

https://*****:*****@github.com/<your_github_group>/<your_github_project>.git

Để kiểm tra mirror hoạt động:

Lưu ý

Tham khảo

  1. meesvandongen.nl/posts/mirror-gitlab-github
  2. GitLab Docs: Set up a push mirror from GitLab to GitHub