LinuxCommandLibrary

copier

updatable project template tool

TLDR

Create project from template

$ copier copy [gh:user/template] [destination/]
copy
Create from local template
$ copier copy [./template] [./project]
copy
Update existing project
$ copier update
copy
Update to specific version
$ copier update --vcs-ref [v2.0.0]
copy
Recopy with new answers
$ copier recopy
copy
Answer prompts non-interactively
$ copier copy --data [name=myproject] [template] [dest]
copy

SYNOPSIS

copier command [options] [arguments]

DESCRIPTION

copier is a project templating tool similar to cookiecutter but with a crucial distinction: it can update existing projects when the template evolves. This makes it ideal for maintaining multiple projects based on a shared template, as you can propagate improvements and bug fixes from the template to all derived projects.
The tool uses Jinja2 templating and supports both Git repository URLs and local paths as template sources. Templates are versioned using Git tags, allowing projects to track which template version they were created from and update to newer versions while preserving local customizations.
copier stores metadata about template answers in the generated project, enabling the update command to intelligently merge template changes with your modifications. This addresses a major limitation of traditional project generators where improvements to the template couldn't be applied to existing projects. The tool requires Python 3.10+ and is particularly popular in Python and web development communities.

PARAMETERS

--data key=value

Answer questions non-interactively
--vcs-ref ref
Git reference (tag/branch)
--trust
Trust template (run tasks)
--pretend
Preview without creating files
--skip path
Skip specific paths
--force
Overwrite without prompting
-a, --answers-file file
Load answers from file

COMMANDS

copy template destination

Create new project from template
update
Update project from template
recopy
Regenerate with new answers

TEMPLATE STRUCTURE

Files ending in .jinja are rendered. Others are copied as-is.

$ template/
├── copier.yml        # Config & questions
├── {{project_name}}/ # Dynamic directory
└── README.md.jinja   # Templated file
copy

CAVEATS

Requires Python 3.10+ and Git 2.27+. Templates versioned by Git tags. Use --trust for templates with tasks.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community