Skip to content

A small utility that allows to mirror external repositories to GitLab, GitHub and possible more.

License

Notifications You must be signed in to change notification settings

bufferoverflow/git-mirror

This branch is 728 commits behind bachp/git-mirror:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

846734a · Nov 26, 2019
Jul 8, 2017
Nov 26, 2019
Jun 26, 2019
Mar 5, 2018
May 16, 2018
Nov 7, 2019
Nov 7, 2019
Nov 7, 2019
Jul 20, 2018
Jun 12, 2017
Mar 19, 2019
Jul 7, 2017

Repository files navigation

Git Mirror

Git Mirror will watch a GitLab or GitHub groups and keep it in sync with external git repositories.

Usage

  1. Create group on your gitlab instance or gitlab.com. e.g. mirror-test
  2. Add a repository you like to sync to. e.g my-project
  3. Add a description to the project in YAML format containing an origin field. e.g. origin: https://git.example.org/my-project.git
  4. Execute set the PRIVATE_TOKEN environment variable a personal access token or your private token and execute git-mirror
export PRIVATE_TOKEN="<personal-access-token>"
git-mirror -g mirror-test

This will sync the group mirror-test on gitlab.com. If you want to sync a group on a different GitLab instance, use the -u flag.

git-mirror -g mirror-test -u http://gitlab.example.org

Multiple concurrent jobs

git-mirror allows to execute multiple mirror jobs in parallel using the -c <n> flag.

git-mirror -g mirror-test -c 8

This will execute at most 8 sync jobs in parallel

Description format

For git-mirror to mirror a repository it needs to know where to sync from. In order to achive this git-mirror expects the description field of a mirrored project to be valid YAML with at least an origin field.

origin: https://git.example.org/my-project.git

A list of currently supported fields

  • origin Source repository to mirror from
  • skip Temporarily exclude a project from syncing by adding skip: true
  • destination Reserved for future use
  • refspec Push only refspec. Add the refspec list to use it. Any valid refspec is possible. E.g.
    refspec: ["master", "2.0", "+refs/tags/*:refs/tags/*"]
    See also https://git-scm.com/book/en/v2/Git-Internals-The-Refspec

Any other fields are ignored

Mirror to GitHub

git-mirror also supports mirroring to GitHub.

This can be done by specifying GitHub as provider:

export PRIVATE_TOKEN="<personal-access-token>"
git-mirror -g mirror-test -p GitHub

This has been tested against github.com but it might also work with on premise installations of GitHub.

Docker

There is also a docker image available. It can be used as follows:

docker run -e PRIVATE_TOKEN="x" bachp/git-mirror git-mirror -g mirror -u http://gitlab.example.com

Building & Installing

In order to build this project you need a least rust v1.18.0. The easiest way to get rust is via: rustup.rs

The project can be built using cargo

cargo build

They're using Git Mirror

License

This project is licensed under the MIT License - see the LICENSE file for details

About

A small utility that allows to mirror external repositories to GitLab, GitHub and possible more.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 91.6%
  • Shell 5.8%
  • PowerShell 1.7%
  • Dockerfile 0.9%