commit 330f0f9253a90976fc6ba5136b0b5fb2a58bb993 Author: Lukas Winkler Date: Fri Dec 30 15:05:57 2022 +0100 first version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..793251f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +repos diff --git a/README.md b/README.md new file mode 100644 index 0000000..10b8d6a --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/sync.py b/sync.py new file mode 100644 index 0000000..f878e9f --- /dev/null +++ b/sync.py @@ -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