# Git to SVN Sync Workflow

This document outlines the best practices for maintaining both a Git repository (GitHub) and a WordPress.org SVN repository.

## Overview

- **Git Repository (GitHub)**: Primary development repository
  - Location: `/Users/stevenmathew/Local Sites/test-origin/app/public/wp-content/plugins/SM-Easy-Post-Migrator`
  - Remote: `https://github.com/StackWP/SM-Easy-Post-Migrator.git`
  - Branch: `publishing1.0`

- **SVN Repository (WordPress.org)**: Distribution repository
  - Location: `~/Desktop/sm-easy-post-migrator`
  - Remote: `https://plugins.svn.wordpress.org/sm-easy-post-migrator`
  - Working Directory: `trunk/`

## Best Practices

### 1. Development Workflow

1. **Make changes in Git repository**
   - All development happens in the Git repo
   - Commit changes to Git with descriptive messages
   - Push to GitHub

2. **Sync to SVN when ready to release**
   - Use the sync script: `./sync-to-svn.sh "Your commit message"`
   - Or manually copy files and commit

3. **Tag releases in SVN**
   - After syncing to trunk, create a tag for the version
   - Example: `svn copy trunk tags/1.1.3`

### 2. Files to Exclude from SVN

The following files/directories should **NOT** be synced to SVN:
- `.git/` - Git metadata
- `.DS_Store` - macOS system files
- `*.swp`, `*.swo`, `*~` - Editor temp files
- `.idea/`, `.vscode/` - IDE settings
- `vendor/` - Composer dependencies (if any)
- `composer.lock` - Composer lock file
- `*.zip` - Build artifacts
- `node_modules/` - Node dependencies (if any)

### 3. Recommended Workflow

#### Option A: Automated Sync Script (Recommended)

```bash
# From the Git repository directory
./sync-to-svn.sh "Your descriptive commit message"
```

The script will:
1. Update SVN repository
2. Copy all files from Git to SVN (excluding dev files)
3. Remove files that were deleted in Git
4. Add new files to SVN
5. Show you the status
6. Ask for confirmation before committing

#### Option B: Manual Sync

```bash
# 1. Update SVN
cd ~/Desktop/sm-easy-post-migrator
svn update

# 2. Copy files (use rsync or cp commands)
# Copy specific files or entire directories

# 3. Add/remove files
cd trunk
svn add <new-files>
svn remove <deleted-files>

# 4. Commit
svn commit -m "Your commit message"
```

### 4. Version Management

When releasing a new version:

1. **Update version in Git:**
   - Update version in `content-migration-pro.php`
   - Update `readme.txt` changelog
   - Commit and push to Git

2. **Sync to SVN:**
   ```bash
   ./sync-to-svn.sh "Release version 1.1.3"
   ```

3. **Create SVN tag:**
   ```bash
   cd ~/Desktop/sm-easy-post-migrator
   svn copy trunk tags/1.1.3
   svn commit -m "Tag version 1.1.3"
   ```

### 5. Testing Before Sync

Before syncing to SVN, ensure:
- [ ] All changes are committed to Git
- [ ] Code follows WordPress coding standards
- [ ] Plugin has been tested
- [ ] Version numbers are updated
- [ ] Changelog is updated in `readme.txt`

### 6. Troubleshooting

#### SVN Conflicts
If you get tree conflicts:
```bash
cd ~/Desktop/sm-easy-post-migrator/trunk
svn resolve --accept working <conflicted-files>
```

#### Files Not Syncing
- Check that files aren't in the exclude list
- Verify file paths are correct
- Ensure SVN repository is up to date

#### Missing Files in SVN
- Run the sync script to copy all files
- Manually add missing files: `svn add <file>`

## Quick Reference

```bash
# Sync to SVN
./sync-to-svn.sh "Your commit message"

# Check SVN status
cd ~/Desktop/sm-easy-post-migrator/trunk && svn status

# Update SVN
cd ~/Desktop/sm-easy-post-migrator && svn update

# Commit to SVN
cd ~/Desktop/sm-easy-post-migrator && svn commit -m "Message"

# Create version tag
cd ~/Desktop/sm-easy-post-migrator
svn copy trunk tags/1.1.3
svn commit -m "Tag version 1.1.3"
```

## Notes

- Always test changes in Git before syncing to SVN
- WordPress.org SVN is the source of truth for published versions
- Keep commit messages descriptive
- Sync regularly to avoid large diffs

