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:
commit
330f0f9253
3 changed files with 27 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.idea/
|
||||
repos
|
8
README.md
Normal file
8
README.md
Normal 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
17
sync.py
Normal 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
|
Loading…
Reference in a new issue