[Bug]: Default behaviour is to delete the template, even if there's no repo to clone yet

Author: TamaMcGlinnCreated May 26, 2026Updated Jun 18, 2026
Labelsbug

What happened?

I know tools often need sharp edges to work effectively, but I've cut myself on this particular case so many times I need to warn people; the default behaviour of cookiecutter is to delete the template dir. This is very annoying when you are creating a new template. For example, make a minimal working cookiecutter template called 'something':

bash
mkdir -p ~/.cookiecutters/cookiecutter-something/{{cookiecutter.app_name}} && echo '{ "app_name": "my_project" }' > ~/.cookiecutters/cookiecutter-something/cookiecutter.json

Now, cookiecutter ~/.cookiecutters/cookiecutter-something works and produces an empty directory my_project.

But cookiecutter gh:AnyUserNameEvenAnInvalidOne/cookiecutter-something --no-input, although it helpfully emits a warning:

The repository https://github.com/AnyUserNameEvenAnInvalidOne/cookiecutter-something.git could not be found, have you made a typo?

... it also silently, irreversibly deletes the template dir.

The default should not be to delete the existing template and then try to download the given url. At the very least, we should first check we can download it before deleting, but really the default should be to go into the existing template dir and do a git pull.

Steps to reproduce

mkdir -p ~/.cookiecutters/cookiecutter-something/{{cookiecutter.app_name}} && echo '{ "app_name": "my_project" }' > ~/.cookiecutters/cookiecutter-something/cookiecutter.json
cookiecutter gh:AnyUserNameEvenAnInvalidOne/cookiecutter-something --no-input

Template

No response

Output / traceback

bash

Cookiecutter version

2.6.0

Python version

3.10

Operating system

Linux

How did you install Cookiecutter?

pip

Additional context

No response

Source: cookiecutter/cookiecutter