feat: add 'copier adopt' command for adopting templates in existing projects#2487
Open
ichoosetoaccept wants to merge 1 commit intocopier-org:masterfrom
Open
feat: add 'copier adopt' command for adopting templates in existing projects#2487ichoosetoaccept wants to merge 1 commit intocopier-org:masterfrom
ichoosetoaccept wants to merge 1 commit intocopier-org:masterfrom
Conversation
…rojects
This adds a new 'copier adopt' subcommand that allows users to adopt a template
for an existing project that was not originally created with Copier.
Unlike 'copier copy', this command:
- Creates new files from the template
- Merges existing files with conflict markers (git-style) instead of overwriting
- Writes a valid .copier-answers.yml for future 'copier update' calls
- Skips tasks by default since conflicts need resolution first
- Handles binary files by creating .rej files (avoids corruption)
Usage:
copier adopt <template_src> [destination_path]
Options:
--conflict {rej,inline} Behavior on conflict (default: inline)
--defaults Use default answers to questions
After adoption, users can resolve conflicts manually, then run template tasks.
Future 'copier update' calls will work with proper 3-way merge.
Includes 13 comprehensive tests covering:
- Core functionality (create, skip, merge, answers file)
- CLI interface and both conflict modes
- Binary file handling (uses .rej to avoid corruption)
- Edge cases: non-git destinations, deep nesting, _subdirectory, exclude patterns
Closes copier-org#2486
50dc51b to
22dae3f
Compare
ichoosetoaccept
added a commit
to detailobsessed/copier-uv-bleeding
that referenced
this pull request
Feb 6, 2026
…#61) ## Summary Add Quick Start section to README with uv tool install, uvx, and copier adopt commands. ## Changes - **README.md**: Expand Quick Start with install, create, uvx, and adopt workflows - **README.md**: Link to upstream copier adopt [PR #2487](copier-org/copier#2487) and [issue #2486](copier-org/copier#2486) - **README.md**: Update Scaffold Prompts table with `repository_provider` and GitLab CI references Fixes #55 <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/detailobsessed/copier-uv-bleeding/pull/61" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
sisp
reviewed
Feb 6, 2026
Member
sisp
left a comment
There was a problem hiding this comment.
Thanks for contributing this valuable feature to Copier, @ichoosetoaccept! 🙇
I think this is a great idea. Before reviewing the changes in detail, a few rather general remarks:
- How about naming the command
onboard? For example, Renovate creates onboarding PRs, it sounds like a more familiar term in a somewhat similar context to me. - Once #2376 lands,
.rejfiles will be dropped. I imagine nobody uses.rejfiles anymore because we have had more familiar inline conflict markers for quite a long time and they have also been the default setting for a while. How about omitting.rejfiles support for this command right from the beginning? This would reduce complexity and avoid code that will likely be removed in the (hopefully) near future again. - Long-term, I think we'll want more flags like
--data. I assume you didn't add them in this PR to keep the scope of the PR manageable. We can add more useful flags in follow-up PRs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
copier adoptsubcommand that allows users to adopt a template for an existing project that was not originally created with Copier.Closes #2486
Motivation
Many users have existing projects they want to bring under Copier management. Currently, the only option is
copier copy --overwrite, which destroys existing customizations. Theadoptcommand provides a safer alternative by merging template files with existing files using conflict markers.What it does
Unlike
copier copy, theadoptcommand:<<<<<<< existing/>>>>>>> template).copier-answers.ymlfor futurecopier updatecalls.rejfiles instead of corrupting them with conflict markersUsage
Options
--conflict {rej,inline}- Behavior on conflict (default:inline)inline: Add git-style conflict markers to the filerej: Create a.rejfile with the template version--defaults- Use default answers to questionsExample workflow
Implementation
The implementation:
run_copymachinerygit merge-filewith an empty base for text files (creates conflict markers).rejfiles for binary files (detected by null bytes in content).copier-answers.ymldirectly (not from a template source)Tests
Added 13 comprehensive tests covering:
inlineandrej).rejto avoid corruption)_subdirectoryAll existing tests continue to pass (215 total).
Checklist