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 bypullfrom a remote repository (styling-exchange);another local repository
styling-barewhich is used to syncstylingandcodeanother local git repository
codewhich has thecode/stylingsubdirectory added as a subtree via a remote branch calledstyling(../styling-bare)a remote
productionrepository which can be updated fromcodewithgit 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:
cdintostyling, pull fromstyling-exchange, thencdintocode, update thestylingsubtree, do some changes tofile1andfile2andfile3, push toproductioncdintocode, do some changes tofile1andfile2andfile3, push changes tostyling-bare(subtree push),cdintostyling, pull fromstyling-bare, push changes tostyling-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 thecoderepository: this does not work, the file is there once I do subtree pull to thestylingsubtree;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 withgit 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 toproduction;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.