tl;dr
Technically your requirement is contradictory.
At a more philosophical level it (seems) to be a clash between open source and corporate philosophy.
Anyhow… I'll suggest some things that come to my mind
Technically
git
either tracks or ignores a file.
- Tracking is easi(est). Just do nothing…other than using git! And any file is tracked.
- Ignoring is nearly as easy — just make sure it matches something in your gitignore file.
- But you cant do both!!
- Main caveat: Moving a file from tracked to ignored is somewhat non-trivial — simply adding the suitable pattern to gitignore wont cut it once tracked. The relevant
Best Practice
Dont start a git project without creating a proper
- gitignore
Also related
- gitattributes
So the first (and somewhat unrealistic)
Suggestion 1
- Start a new git project
- Make proper gitignore and gitattribute files
- Debug if necessary with git-check-ignore
- Copy,add,commit your normal files
- Copy, add, status the not-to-be-tracked files. Status should be clean
But as I said this seems to be not quite what you want because you do want some kind of shared but untracked files.
So you need to
Untrack tracked files
You actually want a git
Post-Clone hook
This is attempted here
But is a bad idea as explained here
Which brings me to the
Philosophical difference
- A corporate-enployer justifiably wants to control what/how its employee-programmers function. Which entails various kinds of machine control
- A random open source software sitting on github that takes control of some other random person's machine is unethical and illegal.
Therefore if you were a big fortune-500 player the natural option would be to fork git itself and add a post-clone hook feature in your fork
A more reasonable and only slightly more inconvenient
Solution 2
- Write your own post-clone but manually callable script
- … which does the requirement of copy if absent leave alone if present
- And add a (manual) step to your team: (1) clone (2) call script
- And dont forget the gitignore!!
If this solution makes sense you may actually prefer
Solution 3
Invert the script-inside-git to git-inside-script
ie ask your team to only download/copy and run a script that
- Runs
git clone
- Checks for these other files' existence/propriety
- Creates/downloads them if necessary (maybe from a source independent of your main repo)