There are dozens of questions regarding the problem, that files listed in .gitignore, but I haven't found a solution among these yet.
I have a repo with several config files. But these config-files are only examples. They should be cloned to local, but if changed locally not be written back. They should only be written to the repo, if I add them via git add <filename>
instead of git add *
.
So far this works locally, if I use git update-index --skip-worktree <path-name>
. git update-index --assume-unchanged [path]
should work as well, but I didn't try it yet. Once I do this, everything works as expected.
But when I clone the repo to a new machine and change this file, changes are tracked and written back, when using git add *
. The expected behaviour would be, that the file is copied to local, but never written back as long as it is mentioned in the .gitignore file.
I'm sure, there is a correct way to do this and I'm doing it wrong, but how?