Sync Git Branch Continuously
Runs a continuous pull and push loop in the background for Git repositories to keep a local branch synchronized with remote branches. This helps ensure that new worktrees based off of main are more up to date.
Workflow Loop
The sync loop periodically executes:
git pull --ff-only <pull-from-remote> <pull-from-branch>git push <push-to-remote> HEAD:<push-to-branch>- Sleeps until timeout (e.g., 60s) or until awakened by an asynchronous
SIGUSR1signal.
Script Location
The synchronization script is located at:
scripts/sync_git_branch_continuously.py under this skill directory.
Running the Continuous Sync Script
To start the continuous sync script as a background daemon process:
# Sync active branch with tracking remote every 60s (default):
REPO_NAME=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
BRANCH_NAME=$(git branch --show-current 2>/dev/null || echo "default")
./.agents/skills/sync-git-branch-continuously/scripts/\
sync_git_branch_continuously.py \
> "/tmp/sync_git_${REPO_NAME}_${BRANCH_NAME}.log" 2>&1 &
Script Options
--pull-from-branch <name>: Remote branch to pull from (defaults to active branch).--push-to-branch <name>: Remote branch to push to (defaults to active branch).--pull-from-remote <name>: Remote repository to pull from (defaults to tracking remote ororigin).--push-to-remote <name>: Remote repository to push to (defaults to tracking remote ororigin).--interval <seconds>: Sleep interval between sync iterations (default:60seconds).
Example with custom source and target destinations:
./.agents/skills/sync-git-branch-continuously/scripts/\
sync_git_branch_continuously.py \
--pull-from-remote upstream --pull-from-branch main \
--push-to-remote origin --push-to-branch feature \
--interval 30 \
> "/tmp/sync_git_main.log" 2>&1 &
Asynchronous Sync Triggers (Signals)
Other processes or agent conversations can asynchronously wake up the daemon and trigger an immediate pull/push cycle without waiting for the interval to expire:
# By PID:
kill -USR1 <PID>
# Or by matching process name:
pkill -USR1 -f "sync_git_branch_continuously.py"
Monitoring & Logs
To check the status or inspect the output of the active background sync loop:
tail -n 20 "/tmp/sync_git_${REPO_NAME}_${BRANCH_NAME}.log"