# autorepoupdate **Repository Path**: mazurdenis/autorepoupdate ## Basic Information - **Project Name**: autorepoupdate - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-19 - **Last Updated**: 2026-03-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Git Sync Tool Robust Git repository synchronization for Linux and Windows. ## Setup 1. **Configure Repositories**: Create a file named `repos.conf` with the following format (one per line): ``` URL|RELATIVE_TARGET_DIRECTORY|BRANCH ``` - `RELATIVE_TARGET_DIRECTORY` — опционально. Если не указан, имя репозитория извлекается из URL. Example: ``` https://github.com/google/gemini-cli.git|gemini-cli|main https://github.com/another/repo.git|utils/another-repo|master https://github.com/user/repo.git||main # клон в ./repo https://github.com/user/repo.git|main # клон в ./repo (без ветки) ``` 2. **Linux (Ubuntu) Setup**: - Ensure `git` is installed. - Make the script executable: `chmod +x sync-repos.sh` - Run it with an optional target root directory: `./sync-repos.sh /path/to/projects` (defaults to current directory) - Optional: Log output to file: `./sync-repos.sh -l /var/log/sync.log /path/to/projects` 3. **Windows Setup**: - Run the PowerShell script with an optional target root directory: `.\Sync-Repos.ps1 C:\path\to\projects` (defaults to current directory) - Optional: Log output to file: `.\Sync-Repos.ps1 -LogFile C:\logs\sync.log C:\path\to\projects` ## Cron Integration (Linux) ### Basic Setup To run the sync every hour, add the following to your crontab (`crontab -e`): ```cron 0 * * * * /bin/bash /path/to/sync-repos.sh >> /path/to/sync.log 2>&1 ``` ### SSH Key Configuration for Cron Cron runs in a minimal environment and may not have access to your SSH agent. To ensure Git can authenticate via SSH: **Option 1: Use SSH key with absolute path (recommended)** 1. Generate SSH key if you don't have one: ```bash ssh-keygen -t ed25519 -C "your-email@example.com" ``` 2. Add the public key to your Git server (GitHub/GitLab/etc.) 3. Test SSH connection: ```bash ssh -T git@github.com ``` 4. Add to crontab with explicit `GIT_SSH_COMMAND`: ```cron 0 * * * * GIT_SSH_COMMAND="ssh -i /home/username/.ssh/id_ed25519 -o IdentitiesOnly=yes" /bin/bash /path/to/sync-repos.sh >> /path/to/sync.log 2>&1 ``` **Option 2: Load SSH agent in cron** ```cron 0 * * * * SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock /bin/bash /path/to/sync-repos.sh >> /path/to/sync.log 2>&1 ``` And add to your `~/.bashrc` or `~/.profile`: ```bash # Start ssh-agent and save socket if [ -z "$SSH_AUTH_SOCK" ]; then SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock" export SSH_AUTH_SOCK fi ``` **Option 3: Use a wrapper script** Create `/path/to/sync-wrapper.sh`: ```bash #!/bin/bash eval "$(ssh-agent -s)" > /dev/null ssh-add /home/username/.ssh/id_ed25519 /path/to/sync-repos.sh ssh-agent -k ``` Make it executable and add to crontab: ```cron 0 * * * * /bin/bash /path/to/sync-wrapper.sh >> /path/to/sync.log 2>&1 ``` ### Example: Daily Sync at 3 AM ```cron 0 3 * * * GIT_SSH_COMMAND="ssh -i /home/username/.ssh/id_ed25519 -o IdentitiesOnly=yes" /bin/bash /path/to/sync-repos.sh /path/to/repos >> /path/to/sync.log 2>&1 ``` ## Features - **Force Update**: Automatically handles rewritten Git history using `fetch` and `reset --hard`. - **Auto-Clone**: Clones missing repositories defined in `repos.conf`. - **Non-Interactive**: Designed for background execution (requires SSH keys or PATs for private repos).