pixi should manage its own `.pixi/.gitignore`
Problem description
Currently the user (or pixi init) must add .pixi to their .gitignore to prevent Git from tracking .pixi/. There are two issues associated with this:
- It is a seemingly unnecessary additional installation step in light of the alternative below.
- Whenever the user checks out a branch from before
.pixiwas ignored, Git will stop ignoring.pixi.
Suggested alternative:
Have pixi create a .pixi/.gitignore file to ignore all files under .pixi/. This way the .pixi/ directory becomes self-contained and unobtrusive from the Git perspective. And this makes initialization of new pixi projects simpler. (IMO you could also get by without .gitattributes so then you're down to just pixi.toml!)
Bonus: repeat with .dockerignore
Another situation where the current state of things is annoying:
I'm working on some open-source project that doesn't use pixi, so I add my own pixi.toml. Ideally I could just leave that and the rest of the pixi files untracked by Git. However, I need to modify .gitignore and be careful not to check in the changes. I rebase quite frequently, so whenever I rebase I have to stash my updated .gitignore and that causes a big mess.
We might not yet be able to entirely get rid of .gitignore in the project root due to .egg-info, see https://github.com/prefix-dev/pixi/pull/1693#issuecomment-2257883284.
If we get rid of .gitignore in the project root, then we will trigger https://github.com/pypa/hatch/issues/304. Probably the safest approach at first is to keep both .gitignores. We could also try and add .pixi to the built-in ignores as per https://github.com/pypa/hatch/pull/493.
EDIT: submitted https://github.com/pypa/hatch/pull/1762 to fix this
I'm working on some open-source project that doesn't use pixi, so I add my own
pixi.toml. Ideally I could just leave that and the rest of the pixi files untracked by Git. However, I need to modify.gitignoreand be careful not to check in the changes.
I also work on an open source project where I've switched to using pixi to manage multiple environments (and finding it works great!) but the project does not use it. My workaround for this is to use the .git/info/exclude rather than the .gitignore to avoid accidentally checking stuff in.
I also work on an open source project where I've switched to using pixi to manage multiple environments (and finding it works great!) but the project does not use it. My workaround for this is to use the
.git/info/excluderather than the.gitignoreto avoid accidentally checking stuff in.
I've had this problem as well, and settled on keeping pixi.toml one level up in the directory tree from the root of the repo. pixi walks up, so this just works when invoking pixi from within the repo (you just have to set cwd for tasks). It has multiple benefits: no need to worry about accidentally deleting or checking in pixi.toml, and you can keep pixi.toml and pixi.lock under version control (see https://github.com/rgommers/pixi-dev-scipystack/ for an example).
I have a PR up for review in #2361.
I also submitted https://github.com/pypa/hatch/pull/1762 to fix https://github.com/prefix-dev/pixi/issues/2115#issuecomment-2379136870 that should AFAIK allow for us to eventually remove .pixi from the .gitignore in the project root.
I believe the .pixi in .gitignore is now redundant now that https://github.com/prefix-dev/pixi/pull/1693 has been merged.
Is it well-documented for what the .egg-info exclude is necessary? In case it's no longer necessary, then pixi no longer needs to touch .gitignore.