1

I want to have a file, let's call it "scratchpad", that:

1) is included in repo, so that everyone cloning the repo will receive a copy of the file, it's "initial" version

2) is ignored by git, so that any local changes made to it are not committed and doesn't even pop up on "changed" list

3) is not updateable by git, so that any local changes are safe from overwrite during pull and merge

First requirement can be accomplished by adding the file to git. Second one is doable via git --assume-unchanged as described here: Git: Ignoring Version-Controlled Files

I can't fulfill the 3rd requirement. The --assume-unchanged have consequences: as git thinks the file is unchanged, it's free to replace its contents at will. So the local edits aren't safe.

(There is a reason for this madness: this file is supposed to contain various developer-specific data, including his/her login and password. Certainly such data should never appear in the repository. However everyone cloning the repo SHOULD be provided with a set of test credentials. This "scratchpad" file contains several constants and methods, so the project won't even compile without it.)

Community
  • 1
  • 1
Agent_L
  • 4,960
  • 28
  • 30
  • How we've done this is have a base config that references an external config they fill out. It is completely ignored by git in the .gitignore and not even an initial version is included. You can have the build system create an empty one if missing. This isn't the most awesome solution, but it was the least awkward to get working when we tried it. – Travis Apr 10 '14 at 14:51
  • @Travis It's Windows Phone project. So either the file is referenced in project - so building will fail without it, or the file is not added to project - which means it won't be deployed to the phone which means it's as good as not existing at all. – Agent_L Apr 10 '14 at 16:41
  • Pre build action to copy it to the output if it exists? But I can see that limiting your options. – Travis Apr 10 '14 at 21:13

1 Answers1

0

I need to do something similar for Django localsettings.py files. In order to handle this, I add localsettings.py to .gitignore and then commit a localsettings.py.example file that contains a basic configuration without any secrets in. On clone, the developer needs to manually copy localsettings.py.example to localsettings.py and fill in the blanks.

wdh
  • 1,612
  • 12
  • 16
  • Yeah, humans can do that - but we're using CI servers, so the project needs to work out of the box : / – Agent_L Apr 10 '14 at 16:27