GithubHelp home page GithubHelp logo

vladisnik / git-bare-sync Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 12 KB

Fetching updates from external git server to local bare git repository

License: MIT License

Python 100.00%
git python gitpython git-server

git-bare-sync's Introduction

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

git-bare-sync's People

Contributors

dependabot[bot] avatar vladisnik avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.