Skip to content

A command for periodically syncing a git repository

Notifications You must be signed in to change notification settings

lunamoonli/git-sync-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

git-sync

git-sync is a command that periodically syncs a remote git repository to a local directory.

This Python implementation is inspired by the Kubernetes module found here: https://github.com/kubernetes/contrib/tree/master/git-sync

Usage

Python

Install/setup

pip install click
git clone https://github.com/jlowin/git-sync.git
cd git-sync && chmod +x git-sync.py

To see available arguments:

./git-sync.py --help

Pass arguments at the command line:

./git-sync.py repo.git --dest /dest/path --branch branch --wait 30

or with environment variables:

GIT_SYNC_REPO=repo.git GIT_SYNC_DEST=/dest/path ./git-sync.py

Docker

By default, the docker container syncs to an internal directory /git.

docker run -v /vol jlowin/git-sync repo.git --dest /vol --wait 100

(This is a spectacularly useless example; you probably want to connect another container to the synced volume.)

Kubernetes

git-sync was originally designed as a side-car module that keeps a (shared) container volume in sync with a remote git repository.

For example, in a replication controller definition:

# this volume holds the synced repo
volumes:
- name: git-sync-volume
  emptyDir: {}

# this container syncs the repo every 1000 seconds
containers:
- name: git-sync
  image: jlowin/git-sync
  volumeMounts:
  - name: git-sync-volume
    mountPath: /git
  env:
  - name: GIT_SYNC_REPO
    value: <repo>
  - name: GIT_SYNC_DEST
    value: /git
  - name: GIT_SYNC_WAIT
    value: "1000"

# this container can access the synced data in /synced
- name: my-container
  volumeMounts:
  - name: git-sync-volume
    mountPath: /synced

About

A command for periodically syncing a git repository

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%