sourcewatch
A file synchronization tool that watches a source directory and syncs changes to a destination, respecting .gitignore rules. Designed to run in Docker/Podman on Windows with a read-only bind mount.
How it works
- Initial sync — copies all non-ignored files from
/hostto/data - Watch — monitors
/hostfor changes and syncs them in real-time
Building
# Build with Go (requires Go 1.24+)
go build -o sourcewatch .
# Build Docker/Podman image
docker build -t sourcewatch .
Usage
# Linux
docker run -v /path/to/source:/host:ro -v watchdata:/data sourcewatch
# Windows
docker run -v c:\source:/host:ro -v watchdata:/data sourcewatch
# Podman (same syntax)
podman run -v c:\source:/host:ro -v watchdata:/data sourcewatch
Flags
-host string Host source directory (default "/host")
-data string Data destination directory (default "/data")
-verbose Enable verbose logging (shorthand for -log-level debug)
-log-level string Log level: debug, info, warn, error, none (default "info")
-dry-run Preview what would be synced without copying
Example
# Build
docker build -t sourcewatch .
# Run with verbose output
docker run -d --name watch \
-v c:\myproject:/host:ro \
-v project-data:/data \
sourcewatch -verbose
# Check logs
docker logs -f watch
# Stop
docker rm -f watch
.gitignore support
- Full gitignore spec:
*,**,[],!negation - Nested
.gitignorefiles (child patterns override parents) - Patterns scoped to their directory
.gitdirectory always skipped
Example .gitignore:
*.log
build/
!important.log
Limitations
- One-way sync only (
/host→/data) /hostmust be read-only?single-character wildcard not supported (go-gitignore limitation)
License
MIT
