1

I created a customApps.json file I that added to git in it's initial state (so it's always there when repo is pulled).

{
  "apps": []
}

After I initially add it to git and pushed, I modified my .gitignore file with the following, and pushed the changes:

*customApps.json

Then I make changes to the customApps.json file.

Desired result: GIT ignores any changes

Actual result: GIT says customApps.json has been modified.

How do I keep the file in GIT in it's initial state, and stop further tracking of changes? This needs to work for anyone who pulls the repo, not just me. So git update-index --assume-unchanged [path] won't work, because other people will need to run that also manually. I trying google and can't find anything that's worked.

  • 1
    You should commit a template of that file to your git repository and add a batch file, or integrate with your build step, a command that looks at your working folder and figures out if the "real" file is present. If not then it should make a fresh copy from the template. If the file is there, leave it. Then you would add the "real" file to .gitignore. The real file here would be named `customApps.json` and a template file something along the lines of `customAppsTemplate.json`. – Lasse V. Karlsen Mar 16 '17 at 16:11
  • 1
    In short, there is no built-in solution for this, you have to adapt your process around git to cope with the situation. – Lasse V. Karlsen Mar 16 '17 at 16:12
  • 1
    `.gitignore` is only used when you ask git to figure out which files to add by itself, with masks. `git add .` and similar will look for files that aren't tracked and that aren't ignored and add those. But once the file is being tracked, `.gitignore` is not used to figure out if the file has changed or not. It is only used to figure out whether to add/track it or not. So you simply can't use `.gitignore` for this, nor is there any other solution built-in. – Lasse V. Karlsen Mar 16 '17 at 16:13
  • Yea, I was afraid this might be the answer. Everything I've read so far was pretty much saying the same thing. Really odd that git doesn't have built in support for this though. – srenert1981 Mar 16 '17 at 16:26
  • The reason there is no built in support for that, is that such a file is not version-controlled. Or, equivalently, it's version-controlled but *in a different repository* (consider sticking your config files in as symbolic links to the real files, over in a version-controlled collection of configurations). – torek Mar 16 '17 at 16:29

0 Answers0