Skip to main content

sync-template

sync-template is a CLI tool designed for managing and synchronizing projects derived from template repositories. It helps you seamlessly merge updates from the template project into your existing project while protecting your local modifications using .syncignore.

Core Features

  • Rapid Initialization: Quickly create new projects from a template repository using git clone --depth 1.
  • Auto-configuration: Automatically sets the template repository as a remote named template.
  • Shortcut Support: Use gh:<owner>/<repo> for GitHub or glab:<owner>/<repo> for GitLab shortcuts.
  • Smart Synchronization: Fetches and merges updates from the template repository via git fetch and git merge.
  • .syncignore Protection: Automatically applies ignore rules after merging to ensure specific files or directories remain in their local state (supports recursive directories).
  • Safety Checks: Automatically verifies the working tree for uncommitted or untracked files before syncing to prevent accidental data loss.

Installation

Ensure your system has Python 3.13+ and Git installed.

To install via pip (after publishing):

pip install sync-template

To install from source (using Poetry):

git clone https://github.com/your-username/sync-template.git
cd sync-template
poetry install

Usage

1. Initialize a New Project

Create a new project from a Git template repository:

sync-template init gh:user/my-python-template my-new-project

Or initialize within an existing repository by adding only the template remote:

cd my-existing-repo
sync-template init gh:user/my-python-template --existing

The init command supports:

  • Full HTTPS URLs: https://github.com/user/repo.git
  • SSH URLs: git@github.com:user/repo.git
  • GitHub shortcuts: gh:user/repo
  • GitLab shortcuts: glab:user/repo

2. Configure Ignore Rules

Create a .syncignore file in the project root. The syntax is identical to .gitignore.

Example:

# Ignore configuration files
config.json
# Ignore the entire content directory (including additions, modifications, and deletions)
content/
# Ignore specific local-only scripts
scripts/local_only.sh

3. Sync Updates

When the template repository has updates, run the following in your project root:

sync-template sync

By default, it syncs the main branch. To sync a different branch, use the --branch parameter:

sync-template sync --branch develop

How It Works

  1. Workflow Check: Ensures there are no uncommitted or untracked changes in the current branch.
  2. Fetch Updates: Executes git fetch template.
  3. Merge Attempt: Executes git merge --no-commit template/<branch>.
  4. Apply Ignore Logic:
    • Traverses all paths matched by .syncignore.
    • If a path existed before the sync, it uses git checkout HEAD to restore its content and automatically resolve conflicts.
    • If a path was added by the template, it physically removes the file and clears it from the Git index.
    • Automatic Cleanup: Recursively cleans up empty directories left behind by the removal process.
  5. Finalization: Prompts the user to review the merge result and commit.

Development & Contribution

This project uses Poetry for dependency management.

  • Run Tests: poetry run pytest
  • Linting Check: poetry run ruff check .
  • Format Code: poetry run ruff format .

License

This project is licensed under the MIT License.

Metadata

Release files for sync-template 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sync-template 0.2.3
File Size Uploaded Provenance Actions
sync_template-0.2.3.tar.gz 6.0 kB With provenance Details for sync_template-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sync-template 0.2.3
File Interpreter ABI Platform Actions
sync_template-0.2.3-py3-none-any.whl Python 3 none any Details for sync_template-0.2.3-py3-none-any.whl

Total release size: 13.7 kB

Release files / sync_template-0.2.3.tar.gz

Download URL sync_template-0.2.3.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3fb19534a09bfa8db9873c12e91a47faad3b0941ebd7fd80ff7b601e5d17bc60
BLAKE2b-256 checksum
How to use checksums
00e4072185ed2e74651de589df6f0fa7acd0e0d2bee5505bed9dcaf71425a6fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 9, 2026.

Transparency log

Release files / sync_template-0.2.3-py3-none-any.whl

Download URL sync_template-0.2.3-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6377aff2525c6899179ac37b52897c0dfefbf9d52a4b2f232a0e8710e7b7351
BLAKE2b-256 checksum
How to use checksums
3bdac2a317a4f61d695c8c6353027b968ce660f7cde6ae5e8dbcfa85539cd419
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 9, 2026.

Transparency log

Security for sync-template 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sync_template-0.2.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page