Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
/ git-bare-sync Public archive

Fetching updates from external git server to local bare git repository

License

Notifications You must be signed in to change notification settings

vladisnik/git-bare-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git bare sync

Small tool for the synchronization between two git repository. But these repositories has type bare.

Can be used with configuration file, for non interactive use such as cron job. And also as ad-hoc script with arguments from CLI.

Written was for using with git server Gitea. It hasn't mirroring through ssh. Therefore tool has some things specific to that git server. For example sub directory over root directory with repositories in configuration file.

Dependencies

Requirements

  • Python >= 3.4
  • Git >= 1.7.0

Some python libs:

Install

PIP way

  1. Clone repository
git clone https://github.com/vladisnik/git-bare-sync.git
  1. Install required libraries
pip install -r requirements.txt

OS package manager way

  • Ubuntu
apt install python3-git python3-yaml
  • RedHat/Centos

First install EPEL repository. Instruction.

yum install GitPython PyYAML

Usage

First you need initialize git repository.

git init --bare

Basic usage:

python git-bare-sync.py --local-repo $HOME/git-server/repository --remote-repo https://github.com/vladisnik/git-bare-sync.git

Remove deleted local branches which no longer exists in remote repository:

python git-bare-sync.py --local-repo $HOME/git-server/repository --remote-repo https://github.com/vladisnik/git-bare-sync.git --remove-branches

With configuration file:

For more information about configuration see section with this title.

python git-bare-sync.py -c config.yml

Use file where will writing status about fetching:

python git-bare-sync.py --local-repo $HOME/git-server/repository --remote-repo https://github.com/vladisnik/git-bare-sync.git --status-file /tmp/repo-sync.json

Configuration

Script can read configuration file was written with YAML. Example is available in this project repo.

Specifies as argument for the script option -c/--config at startup.

Configuration file has following structure:

  • repo_root — Local directory with repositories where stored git repositories subdirectories.
  • remote_server — Main git server which will set as remote in repository and where from will fetching updates.
  • remote_user — User which will used for connect to git server through ssh.
  • metrics — File where will write statuses about fetching.
  • remove_local_branches - Flag in charge of removing local git branches which no longer exists in remote repository. It corresponds to git option --prune.
  • repos
    • subdirectory — Directory which stored set of git repositories as list.
      • git_repo — Name of local git repository with value name of remote repository.

License

This project uses the following license: MIT

About

Fetching updates from external git server to local bare git repository

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages