So I can do something like this: Stop tracking files in git (without deleting them)
But this only affects my git.
There are some default settings file that is already tracked in the remote repository, how do I remove the tracking on that file without deleting the files? I don't want to remove it from the remote repository but that file is necessary to run the application, so anyone doing fresh install needs that file, so they should have that file when they do git clone.
But for development, anyone of the devs can make changes to the files, but those changes SHOULD NEVER be tracked, only the default value should persist in the remote repository.
I tried adding the files to .gitignore list, but it doesn't work - because it's already being tracked, I assume? I would like for everyone to have that file, but everyone should not be able to make changes to the file.
So how do I do this?
how do I remove the tracking on that file without deleting the files?
git rm --cached -- afileToIgnore
It will be removed from Git index, but will remain on the disk locally.
If that file is then added to .gitignore
, a git status
won't show it anymore to be added/changed.
However, that would record the file as being deleted from the Git repo, which is not what you want.
So the actual solution is to then add that same file as a template
copy aFileToIgnore aFileToIgnre.tpl
git add aFileToIgnre.tpl
git commit -m "record template value file"
And then declare a smudge content filter driver which, automatically, will re-generate that file (ignored, since it is in .gitignore
)
smudge
script (which you can version)
copy aFileToIgnore.tpl aFileToIgnre
See also "How can I track system-specific config files in a repo/project?"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With