Repository Management
Manage git repositories centrally and connect them to multiple projects with automatic indexing and version control.
Overview
WDG supports two repository management approaches:
- Central Repositories: Clone once, use across multiple projects
- Project-Specific Repositories: Per-project repository clones
Central Repository Management
Clone Repository
bash
wdg repo clone <url> [name] [branch]Examples:
bash
# Clone with auto-generated name
wdg repo clone https://github.com/client/wp-content
# Clone with custom name
wdg repo clone https://github.com/client/theme client-theme
# Clone specific branch
wdg repo clone https://github.com/client/plugin client-plugin develop
# Clone with SSH
wdg repo clone git@github.com:client/repo.gitWhat it does:
- Clones repository to
repositories/<name>/ - Installs git hooks for auto-indexing
- Indexes code for AI search
- Makes available for project connections
List Repositories
bash
wdg reposOutput:
Central Repositories:
wikit-core
Path: repositories/wikit-core
Branch: main
Status: ✓ Clean
Last commit: abc123 (Updated 2 hours ago)
Indexed: Yes (12,450 vectors)
Used by: 3 projects
client-theme
Path: repositories/client-theme
Branch: develop
Status: ⚠ Modified (5 files)
Last commit: def456 (Updated 1 day ago)
Indexed: Yes (2,340 vectors)
Used by: 1 projectPull Repository Updates
bash
wdg repo pull <name>Example:
bash
wdg repo pull client-themeOutput:
Pulling updates for client-theme...
From https://github.com/client/theme
abc123..def456 develop -> origin/develop
Commit history:
def456 - Add mobile responsive styles (2 hours ago)
abc321 - Update header layout (5 hours ago)
xyz789 - Fix navigation bug (1 day ago)
✓ Repository updated
✓ Re-indexing changed files...
✓ 15 files indexed (234 new vectors)
Projects using this repository:
→ my-site (will use updates on next restart)
→ client-website (will use updates on next restart)Pull All Repositories
bash
wdg repo pull --allUpdates all central repositories.
Connect Repository to Project
bash
wdg repo connect <project> <repo-name> [--type=wp-content|theme|plugin]Examples:
bash
# Connect as full wp-content
wdg repo connect my-site client-content --type=wp-content
# Connect as theme only
wdg repo connect my-site client-theme --type=theme
# Connect as plugin
wdg repo connect my-site custom-plugin --type=pluginConnection Types:
| Type | Mount Point | Use Case |
|---|---|---|
wp-content | /var/www/html/wp-content/ | Full wp-content directory |
theme | /var/www/html/wp-content/themes/<name>/ | Individual theme |
plugin | /var/www/html/wp-content/plugins/<name>/ | Individual plugin |
mu-plugin | /var/www/html/wp-content/mu-plugins/<name>/ | Must-use plugin |
Repository Status
bash
wdg repo status <name>Output:
Repository: client-theme
Path: repositories/client-theme
Remote: git@github.com:client/theme.git
Branch: develop (tracking origin/develop)
Status:
Modified: 5 files
Staged: 0 files
Untracked: 2 files
Recent commits:
def456 (HEAD) Add mobile styles (2 hours ago) - John Doe
abc321 Update layout (5 hours ago) - Jane Smith
xyz789 Fix navigation (1 day ago) - John Doe
Used by projects:
→ my-site (connected as theme)
→ client-website (connected as theme)Delete Repository
bash
wdg repo delete <name> [--force]🚨 DANGER
This permanently deletes the repository from disk!
Project-Specific Repositories
Add Repository to Project
bash
wdg <project> repo add <url> [branch]Examples:
bash
# Add to specific project
wdg my-site repo add https://github.com/client/plugin
# Add specific branch
wdg my-site repo add https://github.com/client/theme developWhat it does:
- Clones to
projects/<project>/repositories/<name>/ - Installs git hooks
- Indexes code
- Project-specific isolation
List Project Repositories
bash
wdg <project> repo listOutput:
Repositories for my-site:
my-site (wp-content)
Type: wp-content
Path: projects/my-site/repositories/my-site
Branch: main
Status: ✓ Clean
Indexed: Yes (1,450 vectors)
custom-plugin (plugin)
Type: plugin
Path: projects/my-site/repositories/custom-plugin
Branch: develop
Status: ⚠ Modified
Indexed: Yes (234 vectors)Update Project Repository
bash
wdg <project> repo pull <repo-name>Remove Repository from Project
bash
wdg <project> repo remove <repo-name>Git Operations
Repository Branches
bash
# List branches
wdg repo branches client-theme
# Switch branch
wdg repo checkout client-theme feature/new-design
# Create branch
wdg repo branch client-theme feature/testRepository Commits
bash
# View commit log
wdg repo log client-theme
# View recent commits
wdg repo log client-theme --since="1 week ago"
# View commits for specific file
wdg repo log client-theme path/to/file.phpDiff and Changes
bash
# View uncommitted changes
wdg repo diff client-theme
# View changes between commits
wdg repo diff client-theme abc123..def456
# View changes for specific file
wdg repo diff client-theme path/to/file.phpRepository Configuration
Configure Git Settings
bash
# Set repository remote
wdg repo remote client-theme \
set-url origin git@github.com:client/new-url.git
# Add additional remote
wdg repo remote client-theme \
add upstream https://github.com/wdg/wikit-theme.git
# List remotes
wdg repo remote client-themeConfigure Branch Tracking
bash
# Set upstream branch
wdg repo set-upstream client-theme develop origin/develop
# Unset upstream
wdg repo unset-upstream client-themeAdvanced Repository Features
Repository Templates
Create reusable repository templates:
bash
# Create template from existing repo
wdg repo template create client-theme wdg-client-template
# Use template for new project
wdg create new-site --template=wdg-client-templateRepository Hooks Management
bash
# List hooks
wdg repo hooks list client-theme
# Enable/disable specific hooks
wdg repo hooks disable client-theme pre-push
# Reinstall all hooks
wdg repo hooks install client-themeSubmodule Support
bash
# Initialize submodules
wdg repo submodule init client-theme
# Update submodules
wdg repo submodule update client-theme
# Add submodule
wdg repo submodule add client-theme \
https://github.com/vendor/library path/to/libRepository Syncing
Sync Strategy
bash
# Pull and re-index (default)
wdg repo sync client-theme
# Pull without indexing
wdg repo sync client-theme --no-index
# Force pull (discard local changes)
wdg repo sync client-theme --forceSync All Projects
bash
# Sync all repositories in all projects
wdg sync --allOutput:
Syncing repositories...
[1/5] wikit-core
✓ Already up to date
[2/5] client-theme (used by: my-site, client-website)
✓ Pulled 3 commits
✓ Re-indexed (15 files changed)
⚠ Projects need restart to use updates
[3/5] custom-plugin (used by: my-site)
✓ Pulled 1 commit
✓ Re-indexed (2 files changed)
Sync complete!
Updated: 2 repositories
Projects affected: 2 (restart recommended)Repository Backup
Backup Repository
bash
# Create archive
wdg repo backup client-theme
# Backup with specific name
wdg repo backup client-theme backups/theme-$(date +%Y%m%d).tar.gzRestore Repository
bash
wdg repo restore backups/theme-20241014.tar.gzWorking with Multiple Remotes
Setup Multiple Remotes
bash
# Add WDG upstream
wdg repo remote client-theme \
add upstream git@github.com:wdg/base-theme.git
# Add client remote
wdg repo remote client-theme \
add client git@github.com:client/theme.git
# List all remotes
wdg repo remote client-themeOutput:
origin git@github.com:client/theme.git (fetch)
origin git@github.com:client/theme.git (push)
upstream git@github.com:wdg/base-theme.git (fetch)
upstream git@github.com:wdg/base-theme.git (push)Pull from Upstream
bash
# Pull WDG updates
wdg repo pull client-theme upstream main
# Merge with client branch
wdg repo merge client-theme mainRepository Workflows
Client Project Workflow
bash
# 1. Clone client repository
wdg repo clone git@github.com:client/wp-content client-site
# 2. Add WDG upstream
wdg repo remote client-site add upstream git@github.com:wdg/wikit-core.git
# 3. Connect to project
wdg repo connect my-project client-site --type=wp-content
# 4. Development...
# 5. Pull WDG updates periodically
wdg repo pull client-site upstream mainMulti-Project Shared Repository
bash
# 1. Clone to central location
wdg repo clone https://github.com/wdg/shared-plugin
# 2. Connect to multiple projects
wdg repo connect project-a shared-plugin --type=plugin
wdg repo connect project-b shared-plugin --type=plugin
wdg repo connect project-c shared-plugin --type=plugin
# 3. Update once, available to all
wdg repo pull shared-plugin
# 4. Restart projects to use updates
wdg restart project-a project-b project-cTroubleshooting
Repository Not Updating
bash
# Check remote connectivity
wdg repo remote client-theme show origin
# Force pull
wdg repo pull client-theme --force
# Reset to remote state
wdg repo reset client-theme origin/main --hardMerge Conflicts
bash
# View conflict files
wdg repo status client-theme
# Abort merge
wdg repo merge client-theme --abort
# Use theirs/ours strategy
wdg repo merge client-theme -X theirsHooks Not Working
bash
# Reinstall hooks
wdg repo hooks install client-theme
# Check hook permissions
ls -la repositories/client-theme/.git/hooks/
# Fix permissions
chmod +x repositories/client-theme/.git/hooks/*Indexing Issues
bash
# Force re-index
wdg index client-theme --force
# Check indexing logs
docker logs wdg-indexer | grep client-theme
# Verify collection
wdg collections list | grep client-themeBest Practices
1. Use Central Repositories for Shared Code
bash
# Good: Shared across projects
wdg repo clone https://github.com/wdg/wikit-core
wdg repo connect project-a wikit-core
wdg repo connect project-b wikit-core
# Bad: Duplicate per project
wdg project-a repo add https://github.com/wdg/wikit-core
wdg project-b repo add https://github.com/wdg/wikit-core2. Regular Updates
bash
# Daily or weekly
wdg repo pull --all
# Before starting work
wdg repo pull $(wdg repos --names)3. Meaningful Branch Names
bash
# Good
feature/user-authentication
fix/header-layout
hotfix/security-patch
# Bad
test
temp
branch14. Keep Repositories Clean
bash
# Remove old branches
wdg repo branch -d feature/completed
# Clean up untracked files
wdg repo clean client-theme -fdSee Also: