The service template moved to 2.0.0 with a wider ruff line length and an .editorconfig, and
forty projects generated from 1.0.0 need it. Each has rewritten its README since. The update
tool exits 0 even though it left conflict markers in the README, so the next commit ships them.
What you get
You will end up with a template update that lands in an edited project and a list of paths the template stops managing after the first generation. A check fails the run when markers remain. This is for platform teams who own a project template and the repositories made from it.
Short answer
Run copier update --vcs-ref v2.0.0 in a clean checkout. Copier reads the answers file, renders
both template versions, and merges the change into your edits. Before the first generation, list
the files the project will own in _skip_if_exists, or in the skip list of .cruft.json for
cruft. Then check for conflict markers yourself, because Copier and cruft both exit 0 when they
leave some.
You will need
Python 3.12 or later, git, and a project generated from a template that has version tags. Verified 2026-11-30 against Python 3.12.3, Copier 9.19.1, cruft 2.16.0, and Cookiecutter 2.7.1. Generating the project in the first place is covered in scaffold a Python API client project with Cookiecutter.
Approaches compared
| Approach | When it fits | What it costs you | When to pick something else |
|---|---|---|---|
| Copier | You choose the template tool, and the template should declare which files it hands over | Another tool and answers file per project, and an exit status of 0 over a conflict | The template is Cookiecutter and rewriting it is not on the table |
| cruft | Projects already come from a Cookiecutter template and you want updates without rewriting it | The skip list lives in each project, so forty projects need forty edits | You control the template and want one list for every project |
| git merge by hand | A few projects, an engineer who knows git, and no tool to adopt | You find the generation commit and the answers yourself, every time, per project | You update more projects than you can merge by hand in a sitting |
Copier and cruft both record what generated the project, so an update is one command. Copier puts the owned-file list in the template, which suits a team that owns the template, while cruft puts it in each project. The hand merge needs nothing installed and is the only one of the three that exits 1 on a conflict.
Build the scenario once per tool
scenario.py builds a template repository with two tags, generates a project from v1.0.0,
commits it, and makes the edits a team makes: a README of its own and an httpx dependency in
pyproject.toml. Then it updates to v2.0.0. Git runs with GIT_CONFIG_NOSYSTEM=1, an empty
global config file, and a fixed identity and date, in a scratch directory per run.
The Copier route is the update command and nothing else:
def copier_update(work, env, owned):
tpl = template_repo("copier", work, env, owned)
proj = work / "billing"
tool("copier", "copy", "--defaults", "--vcs-ref", "v1.0.0", str(tpl), str(proj), cwd=work, env=env)
git("init", "-q", "-b", "main", cwd=proj, env=env)
commit_all(proj, env, "generate from template 1.0.0")
edit_project(proj, env)
r = tool("copier", "update", "--defaults", "--vcs-ref", "v2.0.0", cwd=proj, env=env)
return proj, "copier update --defaults --vcs-ref v2.0.0", r
Copier reads the template’s address and the _commit it generated from in .copier-answers.yml.
The updating guide
says never to edit that file by hand.
Run the update and read what it left
python3 scenario.py copier
copier update --defaults --vcs-ref v2.0.0
exit status 0
M .copier-answers.yml
?? .editorconfig
UU README.md
M pyproject.toml
conflict in README.md: <<<<<<< before updating / >>>>>>> after updating
conflicts left: README.md
stderr: Updating to template version 2.0.0
The template’s changes arrived. pyproject.toml holds both the httpx dependency and the
wider line length, and .editorconfig arrives as a file git has not seen. The README conflicts because the project and the
template both rewrote its third line. The script prints what the tool left and then every line the
tool printed. Copier’s one line names the version and no conflict, and Copier exited 0, so
scenario.py exits 1 itself. On git 2.55 or later Copier prints one more line, as “When it goes
wrong” explains.
Hand the README to the project
The README stopped being the template’s the day the team wrote its own. Write that down before the first generation, in one list:
# Written down before the first generation: after it, these belong to the project.
OWNED = ["README.md"]
For Copier, the template declares the list as
_skip_if_exists.
--owned appends it to copier.yml:
python3 scenario.py copier --owned
copier update --defaults --vcs-ref v2.0.0, with README.md owned by the project
exit status 0
M .copier-answers.yml
?? .editorconfig
M pyproject.toml
no conflicts
stderr: Updating to template version 2.0.0
The README keeps the project’s text, and every other change still arrives. The Copier reference
describes _skip_if_exists as skipping a file only if it already exists, so a project that
deletes its README gets the template’s back on the next update.
Check it worked
The tests run all six combinations and assert on what each left on disk as well as on the exit status. One deletes the README and runs the update both with the skip list and without it. Two pin the lines Copier prints and their place at the end of the script’s output:
python3 test_scenario.py
ok test_conflicts_finds_rej_files_and_markers_in_untracked_files
ok test_conflicts_ignores_marker_like_lines_that_are_not_a_conflict
ok test_copier_exits_0_with_a_conflict_in_the_readme
ok test_copier_output_names_the_version_and_no_conflict
ok test_copier_skip_if_exists_brings_a_deleted_readme_back
ok test_copier_skip_if_exists_leaves_the_readme_alone
ok test_cruft_exits_0_with_a_conflict_in_the_readme
ok test_cruft_skip_leaves_the_readme_alone
ok test_git_merge_exits_1_with_a_conflict_in_the_readme
ok test_git_merge_without_the_owned_paths_is_clean
ok test_the_script_exits_1_when_a_conflict_is_left
ok test_the_tool_output_comes_last_so_only_the_end_depends_on_git
ok test_the_tool_output_is_printed_whole
13 tests, 0 failed
conflicts() reads git status --porcelain=v1 -z --untracked-files=all, so a file git has never
seen, or one with an odd name, still counts. It scans every file for a <<<<<<< line followed by
======= and a >>>>>>> line, so one marker-like line in a guide to git does not count. It
also flags every name ending .rej, because Copier’s --conflict rej mode leaves rejection
files instead of markers.
When it goes wrong
Copier warns about the version of git when git is 2.55 or later. There it prints
Make sure Git >= 2.24 is installed to improve updates. after the line that names the version.
Git 2.55 made a few
git diff options take only non-negative integers, and
--inter-hunk-context is one.
Copier 9.19.1 passes it -1
in a call to git diff-tree. When that call fails, Copier prints the line and repeats the call
with 0.
The suite here passes on git 2.43.0 and on git 2.56.1, so in these scenarios the update left the
same files either way. Check the tree as before, and leave git as it is.
cruft prints its success line over a conflicted project. With the same edits and the Cookiecutter form of the template, the note git wrote about the conflict went to stderr, the success line to stdout, and the exit status was 0:
python3 scenario.py cruft
cruft update --checkout v2.0.0 --skip-apply-ask
exit status 0
M .cruft.json
A .editorconfig
UU README.md
M pyproject.toml
conflict in README.md: <<<<<<< ours / >>>>>>> theirs
conflicts left: README.md
stdout: Good work! Project's cruft has been updated and is as clean as possible!
stderr: Falling back to direct application...
stderr: Applied patch to 'README.md' with conflicts.
stderr: Applied patch to 'pyproject.toml' cleanly.
stderr: U README.md
cruft 2.16.0 applies the template diff with git apply -3, prints the error git reported, and returns.1
Add the owned paths to the skip list in .cruft.json, and test_cruft_skip_leaves_the_readme_alone
shows the README untouched.
The hand merge conflicts in the same file, and it is the one route that says so in its exit status:
python3 scenario.py by-hand
git merge --no-commit --no-ff template-update
exit status 1
A .editorconfig
UU README.md
M pyproject.toml
conflict in README.md: <<<<<<< HEAD / >>>>>>> template-update
conflicts left: README.md
stdout: Auto-merging README.md
stdout: CONFLICT (content): Merge conflict in README.md
stdout: Auto-merging pyproject.toml
stdout: Automatic merge failed; fix conflicts and then commit the result.
The branch starts at the commit the project was generated in, tagged template-1.0.0, and takes a
fresh Cookiecutter render of v2.0.0. Leave
the owned paths out of that render and the merge is clean.
When not to do this
Do not adopt Copier to update three projects. The hand merge took one branch and one git merge,
and its exit status was the only one of the three that reported the conflict.
Do not rely on the cruft skip list across a fleet. It lives in each project’s .cruft.json, so a
project that forgot the entry gets the conflict the others avoided.
Do not trust an update tool’s exit status as the CI gate. Copier and cruft both returned 0 over a
conflicted README here; check the tree, as conflicts() does, or Copier’s documented pre-commit
hook will.2
Do not skip a path the template still needs to change, such as pyproject.toml. A skipped file
stops receiving fixes, so keep the owned list to files the project rewrites.
Related how-tos
Last verified
Verified 2026-11-30 against Python 3.12.3, Copier 9.19.1, cruft 2.16.0, Cookiecutter 2.7.1, and
git 2.43.0. Every output block is what the command preceding it printed, run against
template repositories that scenario.py builds locally. The same commands ran on Python 3.14.4
with git 2.56.1, where Copier printed its second line.
Footnotes
-
The message comes from
_apply_three_way_patchin the cruft source, which catches the failedgit apply -3, prints its stderr, and retries with rejection files only when the repository is still clean. A three-way apply that wrote conflict markers has left it unclean, so the retry never runs and the success message follows. ↩︎ Back to text -
The updating guide suggests the
check-merge-conflicthook from pre-commit for inline markers, and a hook that refuses.rejfiles for the other mode. It also notes that the default inline markers are much like the ones agit mergewrites, which thegit mergerun on this page bears out apart from the labels. ↩︎ Back to text