Ignore untracked files inside a specific folder

Hello!

I have a directory in my git repo, that I don’t want to be changed ever.
One approach I had was to put that folder in a different repo and use it as a subrepo to my current one.

Another approach was just to copy the whole folder into my repository. The main issue is that this folder will be changed a lot while running the code locally, but I dont want to push anything upstream and I want git to ignore all of it.

I’ve used git update-index --skip-worktree successfully for already tracked files in those folders. However, new additions still come up as unstaged files.

What would be the best way to tell git to “lock” that folder for changes and ignore everything, and let the folder remain in the repo?

Thanks in advance!

Update:
I ended up creating a new repository for the folder in question and added it as a submodule to my repository. Also added ignore=all to the newly created gitmodules file.

Seems to work fine this far!

Put a .gitignore file with the * pattern into that folder. Mind that that will only ignore untracked files, not changes to existing ones.

1 Like

Thank you, see my edit above!

1 Like