← 返回命令列表

Linux command

copier 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create project from template

copier copy [gh:user/template] [destination/]

Create from local template

copier copy [./template] [./project]

Update existing project

copier update

Update to specific version

copier update --vcs-ref [v2.0.0]

Recopy with new answers

copier recopy

Answer prompts non-interactively

copier copy --data [name=myproject] [template] [dest]

说明

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.

参数

--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

FAQ

What is the copier command used for?

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.

How do I run a basic copier example?

Run `copier copy [gh:user/template] [destination/]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --data _key=value_ do in copier?

Answer questions non-interactively