A simple local server that livereloads local source files via a containerized git server with advanced rsync filtering support.
git-livereload creates a containerized git server that continuously syncs files from your local development directory to a git repository, automatically committing changes and making them available via HTTP. It supports sophisticated file filtering using rsync's include/exclude patterns.
- Automatic Git Commits: Watches for file changes and commits them automatically
- HTTP Git Server: Serves git repository over HTTP with basic authentication
- Advanced Filtering: Support for include/exclude patterns with proper rsync rule ordering
- Webhook Support: Optional webhook notifications on commits
- Docker-based: Easy deployment with Docker Compose
GIT_USERNAME
(default:git
) - Username for HTTP basic authenticationGIT_PASSWORD
(default:p@$$w0rd
) - Password for HTTP basic authenticationWEBHOOK_URL
- Optional webhook URL to notify on commitsVERIFY_SSL
(default:true
) - Set tofalse
to disable SSL verification for webhooks
The system supports three types of rsync filtering:
Specifies which files/directories to include. When set, everything else is excluded by default.
# Include only the 'kustomize' directory
RSYNC_INCLUDE=kustomize
# Include multiple directories
RSYNC_INCLUDE=src,docs,config
# Include nested paths
RSYNC_INCLUDE=app/src,app/config
How it works:
- Automatically generates directory traversal rules (
--include=dir/
for each path component) - Includes all contents of specified paths (
--include=path/***
) - Adds
--exclude=*
to exclude everything else
Specifies files/directories to exclude from the sync.
# Exclude common build artifacts
RSYNC_EXCLUDE=node_modules,*.log,build,dist
# Exclude with patterns
RSYNC_EXCLUDE=*.tmp,*.cache,test/*
Protects files from deletion during sync (uses rsync's protect filter).
# Protect configuration files
RSYNC_PROTECT=.env,config.local.yaml
# Only sync 'kustomize' directory, exclude everything else
RSYNC_INCLUDE=kustomize
Generates rsync args: --include=kustomize/*** --exclude=*
# Include 'kustomize' but exclude 'kustomize/protected' subdirectory
RSYNC_INCLUDE=kustomize
RSYNC_EXCLUDE=kustomize/protected
Generates rsync args: --include=kustomize/*** --exclude=kustomize/protected --exclude=*
# Include multiple directories with nested structure
RSYNC_INCLUDE=app/src,app/config,docs
Generates rsync args:
--include=app/ --include=app/src/*** --include=app/config/*** --include=docs/*** --exclude=*
RSYNC_INCLUDE=src,config
RSYNC_EXCLUDE=src/test,*.log,*.tmp
RSYNC_PROTECT=config/.env
The system follows rsync's rule ordering requirements:
- Include rules are processed first (directory traversal + content inclusion)
- Exclude rules are processed next
- Protect rules are processed last
- When includes are specified, an automatic
--exclude=*
is added at the end
services:
git-livereload:
build:
context: ./git-livereload
image: git-livereload:latest
ports:
- "8080:80"
volumes:
- ./my-project:/repos/mount/blueprint
environment:
GIT_USERNAME: myuser
GIT_PASSWORD: mypassword
services:
git-livereload:
build:
context: ./git-livereload
image: git-livereload:latest
ports:
- "8080:80"
volumes:
- ./my-project:/repos/mount/blueprint
environment:
GIT_USERNAME: myuser
GIT_PASSWORD: mypassword
# Only include 'kustomize' directory
RSYNC_INCLUDE: kustomize
# Exclude protected subdirectory
RSYNC_EXCLUDE: kustomize/protected
# Protect environment files
RSYNC_PROTECT: .env,config.local.yaml
/repos/
├── mount/blueprint/ # Mounted source directory (read-only)
├── serve/blueprint/ # Working git repository
└── git/blueprint.git/ # Bare git repository
Once running, you can clone the repository:
git clone http://myuser:mypassword@localhost:8080/blueprint.git
The include functionality implements rsync's complex rule requirements:
- Directory Traversal: For path
app/src
, generates--include=app/
to allow traversal - Content Inclusion: Adds
--include=app/src/***
to include all contents - Default Exclusion: Automatically adds
--exclude=*
when includes are specified - Duplicate Prevention: Avoids duplicate directory traversal rules
Example transformation:
RSYNC_INCLUDE=app/src,docs
Becomes:
rsync --include=app/ --include=app/src/*** --include=docs/*** --exclude=*
- Include only source directories:
RSYNC_INCLUDE=src,docs
- Exclude build artifacts:
RSYNC_EXCLUDE=build,dist,node_modules
- Include only configs:
RSYNC_INCLUDE=kustomize,config
- Exclude sensitive data:
RSYNC_EXCLUDE=kustomize/secrets
- Protect local overrides:
RSYNC_PROTECT=.env.local
- Include specific app modules:
RSYNC_INCLUDE=apps/frontend,apps/api
- Exclude test directories:
RSYNC_EXCLUDE=*/test,*/tests
Check container logs to see the actual rsync commands being executed:
docker-compose logs git-livereload
Use rsync directly to test your patterns:
rsync -av --include=kustomize/*** --exclude=* /source/ /dest/
- Empty sync: Check that include patterns are correct and directories exist
- Unexpected files: Verify exclude patterns and rule ordering
- Permission errors: Ensure proper file permissions in mounted volumes
The system runs three main processes:
- nginx: HTTP server for git repository access
- fcgiwrap: CGI wrapper for git-http-backend
- sync.sh: Continuous file synchronization and git operations
File changes trigger rsync operations that respect the configured include/exclude patterns, followed by automatic git commits and pushes to the bare repository.