This is a Windows-based tool intended to synchronize pairs of repositories between an Original (upstream) and a Bridge (clone) to ensure both remain identical.
For each repository pair defined in the CSV, the script performs the following:
- Fetch: Pulls latest changes from the Original repo.
- Rebase: Re-applies Bridge commits on top of the latest Original commits.
- Note: If a merge conflict is detected, the script will automatically abort the rebase for that repository and skip to the next one to prevent the script from crashing.
- Bridge Update: Pushes the rebased result to the Bridge repo (
origin). - Original Update: Pushes the result back to the Original repo (
upstream). This ensures the Original repo is updated with any changes made in the Bridge.
- Prerequisites:
- Existing Repositories: The target repositories must already exist on your Git hosting provider (e.g., GitHub, GitLab, Bitbucket). This tool does not create new repositories.
- Git: Must be installed and available in your system PATH.
- Write Access: You must have permissions to push to both the Original and Bridge repositories.
- Authentication: Ensure SSH keys or credentials are configured for your Git hosting providers.
- CSV Configuration: Copy
repositories.csv.templatetorepositories.csvand update it. The columns are:repo_original: URL of the source repository.repo_clone: URL of your bridge repository.branch: The exact branch name to sync (e.g.,main,master).
The script will create a sync_workdir folder in the tool's directory to handle the cloning and syncing process. Run the script from your terminal using the following command:
powershell -ExecutionPolicy Bypass -File "sync_repos.ps1"