Skip to content

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:

  1. Central Repositories: Clone once, use across multiple projects
  2. 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.git

What it does:

  1. Clones repository to repositories/<name>/
  2. Installs git hooks for auto-indexing
  3. Indexes code for AI search
  4. Makes available for project connections

List Repositories

bash
wdg repos

Output:

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 project

Pull Repository Updates

bash
wdg repo pull <name>

Example:

bash
wdg repo pull client-theme

Output:

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 --all

Updates 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=plugin

Connection Types:

TypeMount PointUse 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 develop

What it does:

  1. Clones to projects/<project>/repositories/<name>/
  2. Installs git hooks
  3. Indexes code
  4. Project-specific isolation

List Project Repositories

bash
wdg <project> repo list

Output:

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/test

Repository 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.php

Diff 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.php

Repository 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-theme

Configure Branch Tracking

bash
# Set upstream branch
wdg repo set-upstream client-theme develop origin/develop

# Unset upstream
wdg repo unset-upstream client-theme

Advanced 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-template

Repository 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-theme

Submodule 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/lib

Repository 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 --force

Sync All Projects

bash
# Sync all repositories in all projects
wdg sync --all

Output:

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.gz

Restore Repository

bash
wdg repo restore backups/theme-20241014.tar.gz

Working 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-theme

Output:

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 main

Repository 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 main

Multi-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-c

Troubleshooting

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 --hard

Merge 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 theirs

Hooks 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-theme

Best 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-core

2. 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
branch1

4. Keep Repositories Clean

bash
# Remove old branches
wdg repo branch -d feature/completed

# Clean up untracked files
wdg repo clean client-theme -fd

See Also:

Released under the MIT License.