Open fresh2dev opened 1 month ago
Thanks for reporting this problem, @fresh2dev! :+1:
You've traced the problem to its root, and I think adding the -f, --force
flag to the git add
command is correct. I'm just trying to better understand your scenario to write a meaningful test. Could you please provide a minimal reproducible example? Your reproduction steps are not complete, there must be a step where you add the file to be git-ignored for this problem to occur.
I created an example repo to reproduce the issue:
https://github.com/fresh2dev/copier-repro-1773
Looking at the commits on this example repo, the steps that cause this problem involve:
.gitignore
.gitignore
Here are the exact steps I followed to repro the issue from this repo:
copier copy -r 1.0.0 https://github.com/fresh2dev/copier-repro-1773 hello-world
cd hello-world
git init
git add .
git commit -am 'init'
.env
to .gitignore
) and commit.copier update -fr 2.0.0
git commit -am 'update to v2'
.env
from .gitignore
)copier update -fr 3.0.0
Stderr: | The following paths are ignored by one of your .gitignore files:
| .env
| hint: Use -f if you really want to add them.
| hint: Turn this message off by running
| hint: "git config advice.addIgnoredFile false"
Describe the problem
In one tagged release of my copier template, I added an entry to a templated
.gitignore
to ignore the file.env
. In a later tagged release, I removed this entry from the templated.gitignore
file. Now, when upgrading templated projects, I get this error:Template
Currently must remain private. =/
To Reproduce
.gitignore
.gitignore
Logs
The stack trace points to the
git add
command here:https://github.com/copier-org/copier/blob/v9.3.1/copier/main.py#L1002
Expected behavior
Copier should force-add the file and proceed without error.
Screenshots/screencasts/logs
No response
Operating system
macOS
Operating system distribution and version
Sonoma 14.6.1
Copier version
9.3.1
Python version
Python 3.12
Installation method
pipx+pypi
Additional context
The stack trace points to the
git add
command here:https://github.com/copier-org/copier/blob/v9.3.1/copier/main.py#L1002
FWIW,
git add
has a flag-f, --force
to "Allow adding otherwise ignored files".As a workaround, the update completes successfully when I exclude the un-ignored file from the update:
copier update --exclude .env