Skip to content

feat: add default .gitignore entries during init (#7)#8

Merged
nmccready merged 7 commits intomainfrom
feat/gitignore-defaults
Apr 6, 2026
Merged

feat: add default .gitignore entries during init (#7)#8
nmccready merged 7 commits intomainfrom
feat/gitignore-defaults

Conversation

@nmccready-tars
Copy link
Copy Markdown

Closes #7

Summary

During sync-agents init, automatically add sensible default .gitignore entries for agent tool directories.

Changes

  • Added add_default_gitignore_entries() function that runs during init
  • Adds .DS_Store if not already present
  • Creates sync-agents section with ignore patterns for tool artifacts:
    • .cursor/* (except !.cursor/rules)
    • .codex/* (except !.codex/instructions.md)
    • .github/copilot/* (except !.github/copilot/instructions.md)
  • Idempotent: Running init multiple times doesn't duplicate entries
  • Smart updates: Detects and restores missing entries if section exists

Behavior

  1. Creates .gitignore if it doesn't exist
  2. Adds .DS_Store if not present (case-insensitive check)
  3. Adds or updates sync-agents section with default patterns
  4. Uses * + ! exception pattern to ignore tool artifacts while keeping symlinks tracked
  5. Running init again updates section with any missing entries

Testing

Tested scenarios:

  • ✅ Fresh repo (no .gitignore)
  • ✅ Existing .gitignore with .DS_Store
  • ✅ Running init multiple times (no duplicates)
  • ✅ Manually removing entries and re-running init (entries restored)

Symlinks remain tracked in git while tool-generated artifacts are ignored.

- sync command appends symlink targets to .gitignore if missing
- Adds header comment '# sync-agents (generated symlinks)'
- Idempotent: never duplicates entries
- Respects --targets (only adds relevant entries)
- Respects --dry-run (shows what would be added)
- Preserves existing .gitignore content
@nmccready nmccready force-pushed the feat/gitignore-defaults branch from d2dc63f to bda26e1 Compare April 6, 2026 04:19
nmccready
nmccready previously approved these changes Apr 6, 2026
nmccready
nmccready previously approved these changes Apr 6, 2026
@nmccready nmccready merged commit 1ab3eb3 into main Apr 6, 2026
5 checks passed
@nmccready nmccready deleted the feat/gitignore-defaults branch April 8, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add default .gitignore entries during init

2 participants