## 1. Database and Models

- [x] 1.1 Create Alembic migration to add `git_mounts` column to `config_profiles` table (JSONB, nullable, default empty list)
- [x] 1.2 Update `ConfigProfile` SQLAlchemy model to include `git_mounts` field
- [x] 1.3 Create Pydantic models for GitMount and GitMountCreate schemas with validation
- [x] 1.4 Add validation for git mount fields (source_path relative or glob, target_path absolute, no path traversal)

## 2. Backend API

- [x] 2.1 Update `POST /config-profiles` endpoint to accept `git_mounts` in request body
- [x] 2.2 Update `PUT /config-profiles/{id}` endpoint to accept `git_mounts` updates
- [x] 2.3 Update config profile response schemas to include `git_mounts` in output
- [x] 2.4 Add validation that referenced repositories exist in the same project
- [x] 2.5 Update `GET /config-profiles/{id}/preview` to include resolved git mounts

## 3. Profile Resolution

- [x] 3.1 Update `config_profile_resolver.py` to include git mounts in resolved profile output
- [x] 3.2 Ensure git mounts from included profiles are merged (with override rules)
- [x] 3.3 Add tests for profile resolution with git mounts

## 4. Instance Startup Integration

- [x] 4.1 Modify instance startup pipeline to process git mounts from resolved profile
- [x] 4.2 Add helper function to clone repository if not present (reusing existing clone service)
- [x] 4.3 Add glob pattern expansion for source_path (using standard glob library)
- [x] 4.4 Add helper function to checkout specified branch after clone
- [x] 4.5 Generate bind mount entries in compose file for each valid git mount
- [x] 4.6 Add error logging for missing repos (non-blocking, mount skipped)
- [x] 4.7 Ensure git mounts are processed in parallel with other startup steps

## 5. Frontend Types and API

- [x] 5.1 Update TypeScript types in `apps/web/src/api/config_profiles.ts` to include GitMount interface
- [x] 5.2 Update API client functions to include git_mounts in create/update payloads
- [x] 5.3 Add validation helpers for git mount form fields

## 6. Frontend UI

- [x] 6.1 Add "Git Mounts" section to config profile editor (below existing mounts)
- [x] 6.2 Create GitMountEditor component with repo selector, source/target path inputs (with glob hint), branch selector
- [x] 6.3 Add "Add Git Mount" button that opens the editor
- [x] 6.4 Display existing git mounts with edit/delete actions
- [x] 6.5 Integrate git mounts into profile save flow (include in form submission)
- [x] 6.6 Add validation feedback in UI (repo exists, paths valid, branch exists)

## 7. Testing and Verification

- [x] 7.1 Backend unit tests for git mount validation
- [x] 7.2 Backend integration tests for profile CRUD with git mounts
- [x] 7.3 Test instance startup with git mounts (verify bind mounts created)
- [x] 7.4 Test auto-clone behavior (clone triggered, mount created)
- [x] 7.5 Test clone failure handling (error logged, mount skipped, startup continues)
- [x] 7.6 Test glob pattern expansion (files matched, limit enforced)
- [x] 7.7 Test branch checkout behavior (success and fallback)
- [x] 7.8 Frontend type check passes
- [x] 7.9 Frontend production build succeeds
- [x] 7.10 Manual end-to-end test: create profile with git mount, start instance, verify files mounted

## 8. Documentation

- [x] 8.1 Update API documentation with new git_mounts fields
- [x] 8.2 Add user guide section for using git repositories in config profiles
- [x] 8.3 Document branch pinning behavior and fallback rules

## 9. External Repository Support

- [x] 9.1 Remove project requirement from git mount validation
- [x] 9.2 Add endpoint to create external repositories (no project_id)
- [x] 9.3 Update list_repositories endpoint to return all user repos
- [x] 9.4 Add endpoint to list external repositories
- [x] 9.5 Update spec: repos can be external (not tied to project)
- [x] 9.6 Update spec: auto-clone to persistent location on every container creation
- [x] 9.7 Update spec: pull updates when creating new containers
- [x] 9.8 Update spec: per-instance isolation (no shared clones)

## 10. UI Improvements

- [x] 10.1 Add ability to create external repositories from git mount editor
- [x] 10.2 Show "+ Add new repository..." option in repo dropdown
- [x] 10.3 Add form fields for repo name and remote URL
- [x] 10.4 Auto-refresh repo list after creating new repository
