1
0
Fork 0
mirror of https://github.com/Findus23/git-mirror.git synced 2024-09-19 15:13:49 +02:00

first version

This commit is contained in:
Lukas Winkler 2022-12-30 15:05:57 +01:00
commit 330f0f9253
Signed by: lukas
GPG key ID: 54DE4D798D244853
3 changed files with 27 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.idea/
repos

8
README.md Normal file
View file

@ -0,0 +1,8 @@
# A simple way to mirror git repositories
```bash
cd repos
git clone --mirror https://source.example
cd repo.git
git remote add --mirror=push target https://target.example
```

17
sync.py Normal file
View file

@ -0,0 +1,17 @@
import subprocess
from pathlib import Path
current_dir = Path(__file__).parent
repo_dir = current_dir / "repos"
source_remote_name = "origin"
target_remote_name = "target"
for dir in repo_dir.glob("*"):
print(dir)
print("pull")
subprocess.run(["git", "remote", "update", source_remote_name], check=True, cwd=dir)
print("push")
subprocess.run(["git", "push", target_remote_name], check=True, cwd=dir)
# --mirror is implicit due to remote config