This question is essentially the opposite of this one.
There are certain files that exist for reasons on the team's remote. They are not frequently changed, but that doesn't matter: having them in my local repository causes issues.
I can very easily delete these files but it means I need to be very careful with how and what I commit. Switching branches when these files have changed can be a pain if the files have changed between those branches.
How can I delete these files locally, keep them on the remote, with the illusion of a clean working tree? I'd like to be able to switch branches and do work (stage/unstage/discard) without the presence of these said files. If they change on one branch and I switch to that branch, the files should remain deleted.
My best workaround so far:
- Delete all the said files after branching (for all of my dev branches).
- Commit.
- Do work as usual.
- Rebase + drop the first commit before opening a pull request.
Steps 1 and 2 can be done with a git hook, but I haven't bothered setting that up.
Thanks!
Also a note on the XY problem ("why would you want to do this"): the "correct" solution is to open a support ticket with the team that built my IDE which I'm already doing. A workaround in the meantime might also help answer this question in case it applies elsewhere.
I find two reasons for asking this:
- My colleague wants local
.pyi
files present on the trunk branch for a Python 3.6 project. PyCharm uses these.pyi
files as a source of truth, e.g.: if you add a function to a file, you must add a stub to the associated.pyi
file or PyCharm won't be able to find or suggest the new function. - GitHub Actions require you to commit your entire
node_modules
directory as well as an entrypoint.js
file when publishing a ref as an Action version. This is problematic with multiple branches of a TypeScript GitHub Action where the developer usually runstsc
before committing since the compiled.js
in the working tree will always conflict when switching branches. Stashing is the correct way to handle this but it can be inconvenient at times.