martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.32k stars 284 forks source link

FR: Ignored files re-appear and get lost when switching to different branches #4559

Closed hgezim closed 21 hours ago

hgezim commented 1 day ago

Is your feature request related to a problem? Please describe.

I'm on revision xyz which has has dir:

- phapi/
- phapi/.gitignore
- phapi/erl_crash.dump
- ...

phapi/.gitignore has erl_crash.dump

When I switch to different branch (abc) that doesn't even have phapi dir, I end up with an untracked phapi dir (I think). When I try to switch back to xyz I get this:

The file '.../phapi/erl_crash.dump' is too large to be snapshotted: it is 2.8MiB; the maximum size allowed is ~1.0MiB. Hint: This is to prevent large files from being added on accident. You can fix this error by:

  • Adding the file to .gitignore
  • Run jj config set --repo snapshot.max-new-file-size 2977833 This will increase the maximum file size allowed for new files, in this repository only.
  • Run jj --config-toml 'snapshot.max-new-file-size=2977833' st This will increase the maximum file size allowed for new files, for this command only

This breaks my flow entirely. In case I decide to handle this issue by blowing away the dir, those files are gone.

Describe the solution you'd like

I don't want untracked files from xyz to show up when I move to another dir. These files are orphans. The new branch may or may not care about these files. If it does care about these files (.env file for example) and it needs to use it somehow, it should have it in .gitignore, if it doesn't then it doesn't care about that file.

Haven't thought much about this but perhaps this could be the algo:

Describe alternatives you've considered

There's an option to update .gitignore automatically but that doesn't feel right.

Additional context

I'm not sure about the mechanics of how I did it, but I've lost .env files before switching from one rev to another and it's quite annoying.

Not being able to switch from one branch to another really quick is very un-jj.

yuja commented 21 hours ago

Closed as a dup of https://github.com/martinvonz/jj/issues/323#issuecomment-1586319508