I have a quite specific workflow and the reason for that is that I use git subtree to include one project inside another:
- a local git repository - stylingwhich is updated by- pullfrom a remote repository (- styling-exchange);
- another local repository - styling-barewhich is used to sync- stylingand- code
- another local git repository - codewhich has the- code/stylingsubdirectory added as a subtree via a remote branch called- styling(- ../styling-bare)
- a remote - productionrepository which can be updated from- codewith- git push production master
It should look like this:
code
|--/.git
|--.gitignore
|--/styling
|  |--file1
|  |--file2.v1
|--file3
styling-bare
styling
|--/.git
|--.gitignore
|--file1
|--file2.v2
There are two use cases for the workflow:
- cdinto- styling, pull from- styling-exchange, then- cdinto- code, update the- stylingsubtree, do some changes to- file1and- file2and- file3, push to- production
- cdinto- code, do some changes to- file1and- file2and- file3, push changes to- styling-bare(subtree push),- cdinto- styling, pull from- styling-bare, push changes to- styling-exchange
I would like to have two completely different and separate versions of file2 in the local repositories styling/styling-bare VS the code/production repositories. I need to get all updates from the styling subtree into code/styling, but I need to track file2 just inside code, without any updates from styling.
I.e. I would like to update the styling subtree in the code repository, but keep my own version of file2 when I do that (while having file1 synced between styling and code and file3 synced between code and production), so that I can push my own version (v1) of file2 to production later.
Is there any elegant way to do that in git without symlinks or some sophisticated hooks?
Note, I have experimented with:
- .gitignore - file2in the- coderepository: this does not work, the file is there once I do subtree pull to the- stylingsubtree;
- different .gitignore versions for different branches, but this breaks once I do merge; 
- I have tried to exclude - file2with .git/info/exclude_from_styling, this has no effect;
- I have tried to remove - file2from index with- git update-index --assume-unchanged styling/file2, but this does not solve my problem;
- this solution will not work for me, because I will not be able to push all the - stylingdirectory to- production;
- I am not sure that a filter driver could help to solve the problem; 
- I need to keep the same name for - file2in all the repositories, so the solution with different names is not helpful either.
 
     
     
     
    