| Crates.io | git-mirror |
| lib.rs | git-mirror |
| version | 0.14.15 |
| created_at | 2018-11-23 09:09:28.652795+00 |
| updated_at | 2025-07-02 18:16:10.139295+00 |
| description | Sync between different git repositories. |
| homepage | |
| repository | https://github.com/bachp/git-mirror |
| max_upload_size | |
| id | 98256 |
| size | 116,735 |
Git Mirror will watch a GitLab or GitHub groups and keep it in sync with external git repositories.
Install git and git-lfs.
mirror-testmy-projectorigin field. e.g. origin: https://git.example.org/my-project.gitPRIVATE_TOKEN environment variable a personal access token or your private token and execute git-mirrorexport 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
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
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
lfs Disable git lfs mirror for a specific repo with lfs: false (default is true), only relevant if git-mirror is started with --lfs
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
Note: If set, this field would override the default (global) refspec from the command line option --refspec, if specified. Multiple refs can be set by repeating the option.
Any other fields are ignored
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.
There is also a container image available. It can be used with docker or podman as follows:
docker run -e PRIVATE_TOKEN="x" ghcr.io/bachp/git-mirror git-mirror -g mirror -u http://gitlab.example.com
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
This project is licensed under the MIT License - see the LICENSE file for details