🔄 Sync
👨🍳 Cookbook
Practical examples and workflows for file synchronization
CLI Commands
Basic Commands
# Sync files from configured source
guardy sync
# Force sync (overwrite local changes)
guardy sync --force
# Dry run (show what would be synced)
guardy sync --dry-runSync Status
# Check sync status
guardy sync status
# Output:
Sync Status:
Source: https://github.com/org/config
Last sync: 2 hours ago
Files tracked: 5
Local changes: 0
Updates available: 2Verbose Output
# Detailed sync information
guardy sync --verbose
# Output:
Fetching from https://github.com/org/config...
✓ Downloaded .guardy.yml
✓ Downloaded .guardyignore
✓ Downloaded hooks/pre-commit
⚠ Skipped hooks/local-test.sh (not in sync config)
✓ Sync completed successfullySelective Sync
# Sync specific files only
guardy sync --files ".guardy.yml,hooks/"
# Sync from different source
guardy sync --source "https://github.com/other-org/config"
# Sync from specific branch
guardy sync --branch "develop"Update Check
# Check for updates without syncing
guardy sync check
# Output:
Updates available:
.guardy.yml (modified 3 days ago)
hooks/pre-commit (modified 1 week ago)
Run 'guardy sync' to updateConflict Resolution
# Skip files with conflicts
guardy sync --on-conflict skip
# Overwrite local changes
guardy sync --on-conflict overwrite
# Interactive prompt for each conflict
guardy sync --on-conflict promptOutput Formats
# JSON output for scripting
guardy sync --format json
# Output:
{
"synced_files": [".guardy.yml", "hooks/pre-commit"],
"skipped_files": [],
"conflicts": [],
"status": "success"
}Organizational Patterns
Shared Team Configuration
Maintain consistent settings across all team repositories:
# Central config repo: team-guardy-config
# Contains: .guardy.yml, .guardyignore, hooks/
# Each project repo syncs from central config
sync:
source: "https://github.com/your-org/team-guardy-config"
files:
- ".guardy.yml"
- ".guardyignore"
- "hooks/"Benefits:
- Single source of truth for security policies
- Team-wide updates deployed instantly
- Consistent enforcement across projects
Multi-Environment Setup
Different configurations per environment:
# Production projects
sync:
source: "https://github.com/org/guardy-prod"
branch: "production"
files:
- ".guardy.yml"
- "hooks/"
# Development projects
sync:
source: "https://github.com/org/guardy-dev"
branch: "develop"
files:
- ".guardy.yml"
- "hooks/"Security Policy Enforcement
Enforce organization-wide security policies:
sync:
source: "https://github.com/security-team/policies"
protected: true # Prevent local modifications
files:
- "security-policies/"
- ".guardy.yml"
auto_sync: true # Always use latest policiesMonorepo Synchronization
Sync common files across monorepo packages:
# Root .guardy.yml
sync:
source: "./shared/guardy-config"
files:
- ".guardy.yml"
- "hooks/"
# Each package inherits root configGit Hooks Standardization
Share git hooks across repositories:
sync:
source: "https://github.com/org/standard-hooks"
files:
- "hooks/pre-commit"
- "hooks/commit-msg"
- "hooks/pre-push"Common hooks to sync:
pre-commit- Secret scanning, formatting, lintingcommit-msg- Conventional commits validationpre-push- Full test suite, build verification
CI/CD Integration
Keep CI/CD security checks in sync:
sync:
source: "https://github.com/org/ci-templates"
files:
- ".guardy.yml"
- ".gitlab-ci-security.yml"
- ".github/workflows/security.yml"Documentation Standards
Sync security documentation templates:
sync:
source: "https://github.com/org/docs-templates"
files:
- "SECURITY.md"
- "CODE_OF_CONDUCT.md"
- ".guardy.yml"