14

I have some configuration files to commit on GIT with default parameters. Users can pull these files and can modify them on their local copy but they must not commit/push.

How can I achieve a similar result? the file gitignore doesn't fit my need because file must be commit only the first time

dafi
  • 3,492
  • 2
  • 28
  • 51
  • 2
    There's no way to enforce this with git. You're best bet is probably to follow the `.config.template` or `.config.defaults` pattern outlined here: http://stackoverflow.com/questions/1396617 . It's the most common approach to managing configuration files in source control. It's not a git specific approach. – CB Bailey Aug 16 '10 at 09:08

1 Answers1

10

Could you use git's "assume unchanged" function? If this is set, git always assumes that the file in question has not been modified. This means that git status, git commit etc. will skip the file. Please note that the user can still push a new version of the file into your remote repo but it will take some extra work to do that.

Here's a question where the usage of "assume unchanged" was discussed more thoroughly.

Community
  • 1
  • 1
Mikael Koskinen
  • 12,306
  • 5
  • 48
  • 63
  • 1
    But how can I force people to not suddenly commit some file? For example I'm writing integration test and everybody should edit config to match local environment. And I want to prevent these changes condif to suddenly be pushed on the server instead of templates. – Alex Zhukovskiy Apr 28 '18 at 11:40